Skip to content

stripDefaults()

stripDefaults<T>(schema: ZodObject<T, $strip>): ZodObject<{ -readonly [P in string | number | symbol]: { [K in string | number | symbol]: T[K] extends ZodDefault<Inner> ? Inner : T[K] }[P] }, $strip>

This function strips default values from a Zod object schema, returning a new schema that does not include any default values. This is useful when you want to validate data without applying defaults.

NOTE: This function only strips top-level defaults and does not handle nested schemas.

Type parameters

T extends Readonly<object>

Parameters

schema: ZodObject<T, $strip>

Returns

ZodObject<{ -readonly [P in string | number | symbol]: { [K in string | number | symbol]: T[K] extends ZodDefault<Inner> ? Inner : T[K] }[P] }, $strip>