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

Schemas
Number

Number schema

A function which creates a parsing rule to ensure that a given value is a number.

Arguments

  1. (Optional): A list of modifiers
  2. (Optional): A custom object with error messages to be displayed when validation fails or there are type errors.

Examples

import { number } from '@nordic-ui/validathor';
 
const numberRule = number('Value must be a number');
 
try {
  const parsedValue = numberRule.parse(123);
  console.log('Parsed value:', parsedValue);
} catch (error) {
  console.error('Parsing failed:', error.message);
}