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 a valid number.
The current schema instance.
Sets the maximum value constraint for the number.
The maximum value allowed.
The current schema instance.
Sets the minimum value constraint for the number.
The minimum value allowed.
The current schema instance.
Marks the schema 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.
Validates the input data against the number schema.
The data to validate.
The validated number.
Generated using TypeDoc
Interface for validating numeric values.
const numberSchema = val.NumberSchema(); numberSchema.min(1).max(10).validate(5); // Validates a number between 1 and 10.
ValidationError If the input is not a valid number or does not meet the constraints.
// Example error message: // "Number Failed Validation for: ✖ Expected a number greater than or equal to 1, but received -1."