fix(isMobilePhone): Fix wrong dv-MV mobile phone matching (issue #2101) by pano9000 · Pull Request #2109 · validatorjs/validator.js

Thanks for your comment, as you make a valid point.

Strictly speaking:
no, these are not valid phone numbers, if there is no + or 00 in front of the country code.

However, I just tried to stick to the same RegExp style like (most if not almost all) the other phone numbers, which are making the + optional, when you don't set the strictMode option to true.
And I just included these technically invalid phone numbers in the tests as well, to test that this "optional" matching works as well :-)

E.g. random examples from isMobilePhone.js:

  • nn-NO currently uses /^(\+?47)?[49]\d{7}$/
  • el-GR currently used /^(\+?30|0)?(69\d{8})$/

both of these will match phone numbers without 00 or + as valid.

a big side note on this topic

Generally speaking the isMobilePhone RegExp do not seem to be very constistent altogether in the way the RegExp are matching the phone numbers:

  • some are checking for the + as mandatory (regardless of strictMode)
  • some are checking for the + as optional
  • many do not check for the 00 prefix, which actually should be valid as well
  • etc.

There's a whole range of different formats in the isMobilePhone, which IMHO should be made a bit more consistent, across all of the different countries (or locales in this case).

However fixing that would be a whole new thingon its own, which I could try to tackle soon as well - the only problem I see is that there are a lot of unmerged PRs in regards to the isMobilePhone, so I am not sure if I should already try to add my changes or wait until these are added?