-
Defendi Alberto authoredDefendi Alberto authored
emailValidator.ts 565 B
export const isEmailValid = (email: string): boolean => {
/**
* The following is the RFC 5322 valid email regex
* Hinted from question https://stackoverflow.com/questions/201323/how-to-validate-an-email-address-using-a-regular-expression
* More on http://emailregex.com/
*/
// eslint-disable-next-line
const VALID_EMAIL_REGEX = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return VALID_EMAIL_REGEX.test(String(email).toLowerCase());
};