Skip to content

Instantly share code, notes, and snippets.

@AshikNesin
Forked from oscarmorrison/validateEmail.js
Created May 27, 2017 06:38
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 AshikNesin/5f64f1a041ba741c4be9fd6a4f1d4f3c to your computer and use it in GitHub Desktop.
Save AshikNesin/5f64f1a041ba741c4be9fd6a4f1d4f3c 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