Last active
May 27, 2017 06:38
-
-
Save oscarmorrison/09acf4c3109d5f72b3f00069fa7a44d1 to your computer and use it in GitHub Desktop.
ES6 email validation
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
// regex from http://stackoverflow.com/questions/46155/validate-email-address-in-javascript | |
const EMAIL_REGEX = /^[-!#$%&'*+\/0-9=?A-Z^_a-z{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-?\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/; | |
const validateEmail = email => { | |
return email | |
&& email.length < 255 | |
&& EMAIL_REGEX.test(email); | |
}; | |
export default validateEmail; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment