validator.js icon indicating copy to clipboard operation
validator.js copied to clipboard

Email validation bug.

Open JustAudrius opened this issue 5 years ago • 10 comments

Validation is wrong.

var validator = require('validator');
console.log(validator.isEmail("[email protected]")); // true

JustAudrius avatar Aug 04 '19 15:08 JustAudrius

Issue #948 had raised some concern on a similar note on email validation. The PR's #967, #1058 and #1063 are trying to solve this issue. I will take some time to check this issue and the above-mentioned issue and PR's, and try to find out a solution for the same. Thanks for sharing @AudriusBuika.

ezkemboi avatar Aug 05 '19 14:08 ezkemboi

also console.log(validator.isEmail("david^[email protected]"));

XDavidT avatar Aug 09 '19 08:08 XDavidT

Thanks, @XDavidT for that feedback. We are currently working on a better way of making isEmail validator better or more accurate. Any feedback, assistance will highly be appreciated. Also, if you have some links to articles of possible invalid or valid emails, or rules for email validator, you can send them here.

ezkemboi avatar Aug 09 '19 08:08 ezkemboi

Thanks, @XDavidT for that feedback. We are currently working on a better way of making isEmail validator better or more accurate. Any feedback, assistance will highly be appreciated. Also, if you have some links to articles of possible invalid or valid emails, or rules for email validator, you can send them here.

Email address is split to 3 section: (Username @ Domain . 'suffix domain list' )

  1. User name: Must start&end with letter or number Inside, user can use dot (.) or hyphen (-) or underscore () for once between Number/Letter Between each number/letter, you can use only one time of '.' and '-' and ''. Check out examples username: "d.-_5vid","d-.avid","2g3e4t5y"

  2. Domain: must start&end with letter/number Also allow to include hyphen '-' as you want, but not underscore '_' at all. Important to notice, domain section can include a lot of dot's '.' in case of sub-domains.

  3. Suffix: must use list of all suffix that exists today.

For 2-3 there is npm that can check that for us: https://github.com/miguelmota/is-valid-domain You can read more about right way to use: https://help.xmatters.com/ondemand/trial/valid_email_format.htm

XDavidT avatar Aug 09 '19 09:08 XDavidT

@XDavidT, we do not need to an npm package to the package for that check. What we could do, is build a robust regex for validating it.

ezkemboi avatar Aug 10 '19 19:08 ezkemboi

hi guys, I'm not sure if this is the right place but I have an existing email that is "[email protected]" but isEmail returns false even if the email address is valid and is existing. Also have "[email protected]" which also causes isEmail to return false. Any idea guys?

moodsey211 avatar Jan 22 '21 13:01 moodsey211

I'm not sure if it's an issue, but i can't use dot in display name, unless i put it into quote:

// some-service.com <[email protected]>
validator.isEmail('some-service.com <[email protected]>', {
  allow_display_name: true,
  require_display_name: true
}); // returns false

// "some-service.com" <[email protected]>
validator.isEmail('"some-service.com" <[email protected]>', {
  allow_display_name: true,
  require_display_name: true
}); // returns true

image

jakub-gawryl avatar Feb 23 '21 13:02 jakub-gawryl

@jakub-gawryl -- can open this as a new bug?

profnandaa avatar Apr 18 '21 16:04 profnandaa

@jakub-gawryl -- can open this as a new bug?

Sure - new issue is created here (#1649).

jakub-gawryl avatar Apr 19 '21 05:04 jakub-gawryl

Also, not working for '+++''+++'[email protected]

harshmangukiya avatar Sep 05 '22 16:09 harshmangukiya