Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Real Regex for the regex option #11

Open
yovanoc opened this issue Dec 16, 2020 · 2 comments
Open

Real Regex for the regex option #11

yovanoc opened this issue Dec 16, 2020 · 2 comments

Comments

@yovanoc
Copy link

yovanoc commented Dec 16, 2020

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

@mfbx9da4
Copy link
Owner

mfbx9da4 commented Dec 21, 2020

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 🎂

@yovanoc
Copy link
Author

yovanoc commented Dec 21, 2020

Thanks for my birthday, I will try to open a PR soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants