Skip to content

Modifiers and transforms ​

Modifiers ​

FunctionNotes
optional(schema)The field may be undefined or absent. See optional()
required(schema)Removes optional(), however many times it was applied
lazy(() => schema)Defers a schema until it is parsed. See lazy()

Schema transforms ​

Each returns a new schema. Types follow the runtime change. See Composing schemas and Partial and required variants for examples.

FunctionNotes
extend(schema, shape)Adds or replaces fields; on a union() of objects, every member gets them
omit(schema, keys)Removes fields. Document system fields are kept
pick(schema, keys)Keeps only the listed fields (plus system fields on documents)
rename(schema, newType)Replaces the _type literal
shallowPartial(schema)Top-level fields optional
shallowRequired(schema)Top-level fields required
deepPartial(schema)All fields optional, recursively
deepRequired(schema)All fields required, recursively