Const
The schema is registered in the BupkisRegistry
with the name Truthy
and
indicates that it accepts anything as valid input for evaluation.
TruthySchema.parse(true); // ✓ Valid
TruthySchema.parse(1); // ✓ Valid
TruthySchema.parse('hello'); // ✓ Valid
TruthySchema.parse([]); // ✓ Valid (arrays are truthy)
TruthySchema.parse({}); // ✓ Valid (objects are truthy)
TruthySchema.parse(false); // ✗ Throws validation error
TruthySchema.parse(0); // ✗ Throws validation error
TruthySchema.parse(''); // ✗ Throws validation error
TruthySchema.parse(null); // ✗ Throws validation error
A Zod schema that validates truthy JavaScript values.
This schema accepts any input value but only validates successfully if the value is truthy according to JavaScript's truthiness rules. A value is truthy if it converts to
true
when evaluated in a boolean context - essentially any value that is not one of the eight falsy values.