tgriesser / checkit

simple, flexible validations for node and the browser
MIT License
223 stars 53 forks source link

Email validation doesn't cover apostrophes #60

Closed gfarrell closed 8 years ago

gfarrell commented 8 years ago

Turns out (who knew?) that apostrophes are allowed in email addresses. Rather embarrassingly one of our customers was unable to login, I discovered that checkit invalidates an email address with an apostrophe in it 😢 .

gfarrell commented 8 years ago

TBH I think the only really sane way of validating email addresses is (.+)@(.+), everything else is prone to failure, perhaps with one exception http://cubicspot.blogspot.co.uk/2012/06/correct-way-to-validate-e-mail-address.html

rhys-vdw commented 8 years ago

@gfarrell Well, (.+)@(.+) permit whitespace. I'd accept a PR with a similarly permissive check (but disallowing whitespace).

gfarrell commented 8 years ago

:+1:

gfarrell commented 8 years ago

Actually, @rhys-vdw, it looks like whitespace is permitted, with conditions, as per the Wikipedia article: https://en.wikipedia.org/wiki/Email_address#Local_part

The whole thing is further complicated by comments. I think that /^(.+)@(.+)$/ is probably the only sensible matcher in these circumstances.

I'll submit a pull request.