Skip to content

Cerces


Cerces / helpers / unsafeZodUnwrap

Function: unsafeZodUnwrap() ​

unsafeZodUnwrap<T>(type): undefined | ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

Defined in: src/helpers.ts:71

Unwraps a Zod type if it has an unwrap method. This is useful for extracting the inner type from wrapper types like ZodOptional or ZodNullable.

Type Parameters ​

T ​

T extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

Parameters ​

type ​

T

The Zod type to unwrap.

Returns ​

undefined | ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

The unwrapped Zod type, or undefined if it cannot be unwrapped.