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

Modifiers
Enumerator

Enumerator modifier

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

Schemas

Arguments

  • input (number[] | string[]): The array of values which the input value must be one of.
  • message (Optional): A custom object with error messages to be displayed when validation fails or there are type errors.

Example

  import { enumerator, number } from '@nordic-ui/validathor';
 
  const schema = number([enumerator([0, 25, 50, 75, 100])]);
 
  try {
    const parsedValue = schema.parse(75);
    console.log('Parsed value:', parsedValue);
  } catch (error) {
    console.error('Parsing failed:', error.message);
  }