Transforms a Zod raw shape by making every property "nullish" (both optional and nullable).
This utility is useful for creating "Patch" or "Partial" schemas where fields can be explicitly set to null or omitted entirely.
null
The Zod raw shape (the internal object structure of a ZodObject).
A new shape where every key maps to a nullish version of the original schema.
const bar = z4.object({ name: z4.string(), age: z4.number()});// Every field in foo is now: string | null | undefinedconst foo = z4.object(toNullish(bar.shape)); Copy
const bar = z4.object({ name: z4.string(), age: z4.number()});// Every field in foo is now: string | null | undefinedconst foo = z4.object(toNullish(bar.shape));
Transforms a Zod raw shape by making every property "nullish" (both optional and nullable).
This utility is useful for creating "Patch" or "Partial" schemas where fields can be explicitly set to
nullor omitted entirely.