-
-
Save AshikNesin/5f64f1a041ba741c4be9fd6a4f1d4f3c 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