Max modifier
A modifier which creates a validation rule to ensure that a given value is less or equal to the given input.
Schemas
number
: Learn more.string
: Learn more.date
: Learn more.array
: Learn more.
Arguments
max
(number | date): The maximum value that the input value must meet or exceed.message
(Optional): A custom object with error messages to be displayed when validation fails or there are type errors.
Example
import { max, number } from '@nordic-ui/validathor';
const schema = number([max(10)]);
try {
const parsedValue = schema.parse(4);
console.log('Parsed value:', parsedValue);
} catch (error) {
console.error('Parsing failed:', error.message);
}