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

Modifiers
Email

Email modifier

A modifier which creates a validation rule to ensure that a given string is an email.

Schemas

Arguments

  • domain (Optional): The domain that the email should end with.
  • message (Optional): A custom object with error messages to be displayed when validation fails or there are type errors.

Example

import { email, string } from '@nordic-ui/validathor';
 
const emailRule = string([
  email("@google.com", {
    domain_error: "Not a permitted email domain",
  }),
]);
 
try {
  const parsedValue = emailRule.parse('johndoe@example.test');
  console.log('Parsed value:', parsedValue);
} catch (error) {
  console.error('Parsing failed:', error.message);
}