0.0.16 • Published 6 years ago

form-validators v0.0.16

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

CircleCI

form-validators

A collection of javascript form validators

isEmail

import { isEmail } from "form-validators";

// Create the email validator
const emailValidator = isEmail();
emailValidator("email@domain.com"); // undefined
emailValidator("not an email address"); // 'not an email address' is not a valid email address.

// Define a custom error message
const customEmailValidator = isEmail("You dun goofed!");
customEmailValidator("email@domain.com"); // undefined
customEmailValidator("not an email address"); // You dun goofed!

// Optionaly pass a function that recieves the email adress to build a custom error message
const dynamicCustomEmailValidator = isEmail(
  ({ value }) => `Hmm... I don't think '${value}' is a valid email address.`
);
dynamicCustomEmailValidator("email@domain.com"); // undefined
dynamicCustomEmailValidator("not an email address"); // Hmm... I don't think 'not an email address' is a valid email address.
0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.2

6 years ago

0.0.0

6 years ago