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.
Protected ReadonlycurrentProtected Optional ReadonlyoperationProtected Optional ReadonlypreviousStatic ReadonlybaseReturns a validator that asserts if this validator and the next passes.
Returns a new ValueSchema intersecting this validator and the next.
Validates 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: stringThe 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
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.
Creates a validator that asserts that the input number is finite.
Creates a validator that asserts that the input number is greater than the provided minimum value.
The minimum (exclusive) the value may be.
Creates a validator that asserts that the input number is at least the provided minimum value.
The minimum (inclusive) the value may be.
Creates a validator that asserts that the input number is less than the provided maximum value.
The maximum (exclusive) the value may be.
Creates a validator that asserts that the input number is at most the provided maximum value.
The maximum (inclusive) the value may be.
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.
Creates a validator that asserts that the input number is a safe integer.
ProtectedselfValidates the provided input, returning a list of error messages, or an empty array if the input passes this validator.
The input to validate.
Optionaloptions: ValidationOptionsValidation 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.
Creates a validator that asserts that the input number is at least the provided minimum and at most the provided maximum values.
The minimum (inclusive) value the input may be.
The maximum (inclusive) value the input may be.
A base class for validation state. Provides methods for chaining.
Subclass constructors must accept a single argument: the new validator.