Zod · Function
z.optional
z.optional creates a schema that accepts undefined in addition to values accepted by another schema. It is also available as the .optional() method.
Last updated
Syntax
z.optional(schema)
// or
schema.optional()In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
z.nullablez.nullishz.exactOptionalZodOptional.optional().unwrap()