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

isEmail fails with valid gmail address #865

Closed
fredrik-smedberg opened this issue Jul 18, 2018 · 7 comments
Closed

isEmail fails with valid gmail address #865

fredrik-smedberg opened this issue Jul 18, 2018 · 7 comments

Comments

@fredrik-smedberg
Copy link

isEmail returns false for this address: [email protected]

@RobertFischer
Copy link

Confirmed.

$ yarn add validator
yarn add v1.7.0
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ [email protected]
info All dependencies
└─ [email protected]
Done in 0.59s. 
$ node
> const isEmail = require("validator/lib/isEmail");
undefined
> isEmail("[email protected]");
false
> 

Confirmed.

See also: #825 and #853.

Looks like it's because the Gmail user validation doesn't allow underscores: https://github.com/chriso/validator.js/blob/9ad2034dceb340ac2f9d9103d392a19f4cffa785/src/lib/isEmail.js#L18 A quick trip around the internet confirms that this is, in fact, the case: Gmail doesn't let you create a username with an underscore. So that is, in fact, a valid email.

@agsdtm7
Copy link

agsdtm7 commented Jul 20, 2018

same thing here with normal gmail without underscore
screen shot 2018-07-20 at 3 24 55 pm
also doesn't work

@tux-tn
Copy link
Member

tux-tn commented Jul 20, 2018

@agsdtm7 your email is not valid, minimal address length for gmail is 6 characters.

@agsdtm7
Copy link

agsdtm7 commented Jul 20, 2018

you are correct now it worked with 6 characters (or more) gmail addresses. Thanks for speedy reply

@patelnav
Copy link

patelnav commented Jul 28, 2018

@RobertFischer
I ran into the same issue when testing things internally. Turns out gmail doesn't usually allow underscores, this validation was added on this commit.

@tux-tn:
2 reasons why this shouldn't be enforced:

  1. Google doesn't specifically say this is enforced. So it doesn't makes sense for a client-side validator to enforce this. Even google in their Examples of regular expressions don't enforce this.

  2. Some of my demo accounts (with dummy email addresses) have underscores @gmail.com. I can no longer log in because validator is blocking it client side! Just a bit of a pain!

@chriso
Copy link
Collaborator

chriso commented Jul 31, 2018

@patelnav see #832 (comment) for an example of gmail restricting usernames to [6,30] chars. Admittedly though, I don't know if this was always the case, or if there are valid, internal gmail addresses with < 6 chars.

Either way, this has caused too many issues. I'll add a flag to control the behavior and default to the previous implementation.

@oliviertassinari
Copy link

oliviertassinari commented Aug 2, 2018

@agsdtm7 your email is not valid, minimal address length for gmail is 6 characters.

Does is mean Larry (Page) can't sign in in my application using validator.js? Hum, unless he is using [email protected] :)

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

7 participants