Optional + Default

Combine .optional() with .default() to accept undefined input while removing it from the output type.

editor.ts
Loading editor...
Waiting for code...
Assign a validation result to a variable to see output here, e.g. const result = schema.validate(data)
Inferred Type

Define a schema to see its inferred TypeScript type.

InferType<typeof schema> automatically derives the TypeScript type from your schema definition.