Arguably-useful Zod schemas for common types and validation patterns.
This module provides reusable Zod schemas for validating constructors,
functions, property keys, promises, and other common JavaScript types used
throughout the assertion system. These tend to work around the impedance
mismatch between BUPKIS and Zod.
These are used internally, but consumers may also find them useful.
For example, we have FunctionSchema which accepts any
function—regardless of its signature. We need this because Zod v4's
z.function() no longer returns a ZodType (ref:
Zod v4 Migration Guide) and so behaves
differently. FunctionSchema allows us to work with functions as values
instead of something to be implemented.
Similarly—but not a new development—z.promise() does not parse a
Promise object; it parses the fulfilled value. This is not what we
want for "is a Promise" assertions, but it can be useful for making sense
of the fulfilled value. To solve this, we have
WrappedPromiseLikeSchema (which explicitly supports
PromiseLike/"thenable" objects).
Arguably-useful Zod schemas for common types and validation patterns.
This module provides reusable Zod schemas for validating constructors, functions, property keys, promises, and other common JavaScript types used throughout the assertion system. These tend to work around the impedance mismatch between BUPKIS and Zod.
These are used internally, but consumers may also find them useful.
For example, we have FunctionSchema which accepts any function—regardless of its signature. We need this because Zod v4's
z.function()
no longer returns aZodType
(ref: Zod v4 Migration Guide) and so behaves differently.FunctionSchema
allows us to work with functions as values instead of something to be implemented.Similarly—but not a new development—
z.promise()
does not parse a Promise object; it parses the fulfilled value. This is not what we want for "is a Promise" assertions, but it can be useful for making sense of the fulfilled value. To solve this, we have WrappedPromiseLikeSchema (which explicitly supports PromiseLike/"thenable" objects).Example