validator.js
validator.js copied to clipboard
Bug Report: Incorrect Regular Expression for Tajikistan (tg-TJ) in validator.js
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
Feel free to open a PR with an official source for the valid operator codes
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
#2554 raised a pr please review