ConstFalsySchema.parse(false); // ✓ Valid
FalsySchema.parse(0); // ✓ Valid
FalsySchema.parse(-0); // ✓ Valid
FalsySchema.parse(0n); // ✓ Valid (BigInt zero)
FalsySchema.parse(''); // ✓ Valid (empty string)
FalsySchema.parse(null); // ✓ Valid
FalsySchema.parse(undefined); // ✓ Valid
FalsySchema.parse(NaN); // ✓ Valid
FalsySchema.parse(true); // ✗ Throws validation error
FalsySchema.parse(1); // ✗ Throws validation error
FalsySchema.parse('hello'); // ✗ Throws validation error
FalsySchema.parse({}); // ✗ Throws validation error
import { createAssertion, use } from 'bupkis';
import { FalsySchema } from 'bupkis/schema';
const falsyAssertion = createAssertion(['to be nothing'], FalsySchema);
const { expect } = use([falsyAssertion]);
expect('', 'to be nothing');
A Zod schema that validates falsy JavaScript values.
This schema accepts any input value but only validates successfully if the value is falsy according to JavaScript's truthiness rules. The falsy values in JavaScript are:
false,0,-0,0n,""(empty string),null,undefined, andNaN.