Skip to content

Bug Report: Incorrect Regular Expression for Tajikistan (tg-TJ) in validator.js #2544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
army003 opened this issue Apr 2, 2025 · 3 comments
Labels

Comments

@army003
Copy link

army003 commented Apr 2, 2025

I recently noticed that the regular expression for Tajikistan (tg-TJ) in validator.js is incorrect. Currently, it does not properly validate all valid Tajik phone numbers.

  • The regex does not account for all valid mobile operator codes in Tajikistan.
  • Some valid phone numbers are incorrectly rejected.

Valid Tajikistan Phone Numbers (Should Pass Validation)
+992 90 1234567
+992 91 7654321
(this phone numbers can't pass the validation)

Reproductions

const validNumber1 = '+992901234567',
const validNumber2 =  '+992911234567',
validator.isMobilePhone(validNumber1) // false
validator.isMobilePhone(validNumber2) // false

Suggested Fix
The correct phone number format should include the following valid operator codes:
00, 55, 88, 90, 91, 92, 93, 95, 98, 99
A more accurate regex would be:
/^(\+992|992)?(00|55|88|90|91|92|93|95|98|99)\d{7}$/

Validator.js version: 13.15.0
Node.js version: v20.9.0
OS platform: macOS

@WikiRik
Copy link
Member

WikiRik commented Apr 2, 2025

Feel free to open a PR with an official source for the valid operator codes

@thenileshmishra
Copy link

I’m interested in resolving this issue. The phone numbers provided are valid and sourced from the official Tajikistan Telecommunications page on the WFP Logistics Cluster website:
https://lca.logcluster.org/34-tajikistan-telecommunications

@ShreySinha02
Copy link
Contributor

#2554 raised a pr please review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants