Validator.js: Email validation bug.

Created on 4 Aug 2019  路  9Comments  路  Source: validatorjs/validator.js

Validation is wrong.

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

Most helpful comment

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.

All 9 comments

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.

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

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.

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"
  1. 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.

  2. 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, 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.

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?

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 -- can open this as a new bug?

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

spyshower picture spyshower  路  3Comments

Maxreglez picture Maxreglez  路  3Comments

rubiin picture rubiin  路  3Comments

malkhuzayyim picture malkhuzayyim  路  4Comments

frontendmonster picture frontendmonster  路  4Comments