Constructs the first link in a schema chain.
Constructs linking to the given previous schema.
Enforces T is in an invariant position. This prevents a validator with more strict rules is assigned to a less strict type, which can cause unexpected validation errors.
ReadonlyassertValidates the given input, asserting that the input is type T.
If the input is not valid, a ValidationError will be thrown.
The input to validate.
Optionalorigin: string
The error origin. ErrorOrigin.API by default.
Optionalpath: readonly string[]
The current field path to this validator.
Returns the input, cast as the validated type T
ReadonlyisReturns true if the input is valid according to this validator.
A short description of the validator.
The composed JSON Schema fragment for this schema, including any describe description. Composes through chaining the same way description does; serialize a complete definition with toJsonSchema.
StaticbaseThe base Object validator validating that the input is an object.
Returns a validator that asserts if this validator and the next passes.
Returns a new ValueSchema intersecting this validator and the next.
Casts the type parameter.
ProtectedchainConstructs a new schema with a validator chaining the current validator with the provided next in an AND operation.
The validator to run after the current.
Returns a new Schema instance the same class with a new validator chaining the current validator with the given next in an AND operation.
ProtectedcloneClones this schema, transforming all validators with the given mutator.
Attaches a human-readable description to this schema, akin to zod's describe.
The description is metadata only; it does not affect validation, and surfaces in the output
of toJsonSchema.
The description to attach.
A clone of this schema carrying the description.
Prepends this validator allowing for null or undefined.
Returns a validator that asserts if this validator or the next passes.
Implementation note: subclasses should not change the schema instance returned unless all chainable validators accept input type 'unknown'.
Returns a new ValueSchema providing the union of this validator and the next.
Prepends this validator allowing for null.
Prepends this validator allowing for undefined.
Casts to a ReadonlyRecord
Returns a validator that asserts that the object's own enumerable properties has keys and values that match their respective validators.
Prototype members are not included.
Numeric keys are validated as strings. For example the object { [0]: 1 } will be passed
to the key validator as '0'.
Returns a validator that asserts that the object's own enumerable properties has string keys and values that match the given validator.
Prototype members are not included.
ProtectedselfSerializes this schema to a JSON Schema definition, suitable for describing the shape to an LLM or other consumer. Works similarly to zod-to-json-schema.
ReadonlyvalidateThe input to validate.
Optionaloptions: ValidationOptions
Validation options.
Optionalpath: readonly string[]
The current field path to this validator.
Returns an array of validation failures. If options.all is not true, only the
first error will be returned.
Chainable object validators for the Record type.