Skip to content

Instantly share code, notes, and snippets.

@kasprownik
Created January 29, 2016 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kasprownik/896478d7ca2f594c45e7 to your computer and use it in GitHub Desktop.
Save kasprownik/896478d7ca2f594c45e7 to your computer and use it in GitHub Desktop.
// src/validators.js
import validUrl from 'valid-url';
import emailValidator from 'email-validator';
export function required(value) {
return !value ? ['This field cannot be empty'] : [];
}
export function url(value) {
return value && !validUrl.isWebUri(value) ? ['This URL is invalid'] : [];
}
export function email(value) {
return !emailValidator.validate(value) ? ['This email address is invalid']: [];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment