Optional__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
ReadonlydescriptionA short description of the validator.
ReadonlyisReturns true if the input is valid according to this validator.
Optional ReadonlyjsonThe JSON Schema fragment this validator contributes, if any.
Fragments compose the same way the description does: chaining validators with and
merges their fragments, and or unions them into an anyOf. Serialize a full schema with
toJsonSchema. A validator with no meaningful shape (for example a bare type check)
may omit this.
ReadonlyvalidateValidates the provided input, returning a list of error messages, or an empty array if the input passes this validator.
The 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.
A Validator can assert that an input matches this validator's schema.