Reference / @getenginex/sdk/extension / strictValue
strictValue()
strictValue<
T>(test,message):ZodMiniType<T>
Custom strict schema: accepts the raw value that passes test (without transforming) and, otherwise, rejects the whole response with VALIDATION_ERROR, in 'warn' mode too, like money. It is the basis of the money helpers; use it for a monetary format they do not cover (e.g. a value in a larger unit, converted afterwards with z.pipe). Even the wrong type (text, null, missing) fails marked as strict: a z.number() would emit invalid_type without the mark and the field would be recovered raw. For SDK packages (via @getenginex/sdk/extension), not for apps.
Type Parameters
T
T
Parameters
test
(value) => boolean
Receives the raw wire value; true accepts.
message
string
Issue message (goes to onValidationIssue and error.details).
Returns
ZodMiniType<T>
Example
const reais = strictValue<number>((v) => typeof v === 'number' && Number.isFinite(v), 'Expected reais')
wire({ total: z.pipe(reais, z.transform((v) => Math.round(v * 100))) })Throws
Nothing: the schema does not throw; the failure becomes VALIDATION_ERROR in the transport.