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

fix(isMobilePhone): correct regex for Tajikistan (tg-TJ) phone numbers

Open army003 opened this issue 7 months ago • 1 comments

This PR updates the regular expression for Tajikistan (tg-TJ) phone numbers in isMobilePhone. The previous regex did not fully cover valid mobile number prefixes and incorrectly allowed some invalid numbers.

Updating the regex to match valid Tajikistan mobile phone prefixes. Adding new valid and invalid test cases to improve accuracy.

https://lca.logcluster.org/34-tajikistan-telecommunications (part with Cellular Companies)

Checklist

  • [+ ] PR contains only changes related; no stray files, etc.
  • [ ] README updated (where applicable)
  • [+ ] Tests written (where applicable)
  • [ +] References provided in PR (where applicable)

army003 avatar Apr 02 '25 08:04 army003

I'm having issues with validating the regex. The old one is indeed incorrect, but I'm unsure what the new one should be. The source you mentioned, says nothing about 00 for example. Other sources I've referenced are the National Numbering Plan submitted at the ITU and Google's libphonenumber

Preferably I would use the source from the ITU or from the website of the government agency responsible for the phone numbers.

WikiRik avatar Apr 02 '25 09:04 WikiRik