The type of elements in the array.
Indicates whether the schema allows undefined
as a valid value.
The type of data that the schema validates, represented as a string.
Coerces the input into the desired array format.
The current schema instance.
Sets the maximum length constraint for the array.
The maximum number of elements allowed in the array.
The current schema instance.
Sets the minimum length constraint for the array.
The minimum number of elements allowed in the array.
The current schema instance.
Ensures the array is not empty.
The current schema instance.
Marks the array as optional, allowing undefined
as a valid value.
The current schema instance.
Parses the input data and returns the parsed value.
This method is typically used to coerce or transform the input data into the desired format.
The input data to parse.
The parsed value.
Ensures all elements in the array are unique.
The current schema instance.
Validates the input data against the array schema.
The data to validate.
The validated array.
Generated using TypeDoc
Interface for validating arrays with various constraints.
const arraySchema = val.ArraySchema(val.NumberSchema()); arraySchema.minLength(2).maxLength(5).validate([1, 2, 3]); // Validates an array with 2 to 5 elements.
ValidationError If the array does not meet the specified constraints.
// Example error message: // "Array Failed Validation for: ✖ Array must have at least 2 elements."