deep-email-validator
deep-email-validator copied to clipboard
Real Regex for the regex option
const emailReg = new RegExp(
/^(([^<>()[\]\\.,;:\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,}))$/
);
/**
* Validate email function with regular expression
*
* If email isn't valid then return false
*
* @param email
* @return Boolean
*/
export const validateEmail = (email: string): boolean => emailReg.test(email);
I use this function in several projects. I think it's more robust than the regex option here, but I need all your other options, so what do you think?
thanks
Hey I've intentionally avoided regex as it can produce false negatives. It would be easy enough to add an extra option - something like validateStrictRegex: true. I would welcome a PR. Oh and happy birthday 🎂
Thanks for my birthday, I will try to open a PR soon