⚠️ This project is still in early alpha. Please report bugs on GitHub.

Modifiers
Max

Max modifier

A modifier which creates a validation rule to ensure that a given value is less or equal to the given input.

Schemas

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);
  }