Skip to content

Instantly share code, notes, and snippets.

@oscarmorrison
Last active May 27, 2017 06:38
Show Gist options
  • Save oscarmorrison/09acf4c3109d5f72b3f00069fa7a44d1 to your computer and use it in GitHub Desktop.
Save oscarmorrison/09acf4c3109d5f72b3f00069fa7a44d1 to your computer and use it in GitHub Desktop.
ES6 email validation
// 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