fix(isEmail): replace all dots in gmail length validation by DasDingGehtNicht · Pull Request #1718 · validatorjs/validator.js

Conversation

@DasDingGehtNicht

The gmail domain specific validator checks the length of the username part and replaces dots as they don't count against the limit. But the replace function only replaced the first dot. Fixed by using regex with g switch.

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable)
  • Tests written (where applicable)

@codecov

fedeci

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add test cases?

@DasDingGehtNicht

tux-tn

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉
Nice catch!

fedeci

'test|123@m端ller.com',
'test123+ext@gmail.com',
'some.name.midd.leNa.me+extension@GoogleMail.com',
'some.name.midd.leNa.me.and.locality+extension@GoogleMail.com',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it was passing the test before? Is the GoogleMail domain part of gmail?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Max length is supposed to be 30 characters without the dots and the email alias (any string after the + character) . Even after removing only one dot the old string length was less than 30

@03-65

I have no idea how to code

@03-65

Could you add test cases?

modified existing test case.
test case: 'some.name.midd.leNa.me.and.locality+extension@GoogleMail.com',
pre-fix: invalid (somename.midd.leNa.me.and.locality = 35 chars)
post-fix: valid (somenamemiddleNameandlocality = 29 chars)

I don't know what you mean and I'm unable to Upload files it tells me

@03-65

profnandaa

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks! 🎉

Labels