-
-
Save kasprownik/896478d7ca2f594c45e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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