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

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

Open army003 opened this issue 7 months ago • 3 comments

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

army003 avatar Apr 02 '25 05:04 army003

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

WikiRik avatar Apr 02 '25 05:04 WikiRik

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

thenileshmishra avatar Apr 05 '25 05:04 thenileshmishra

#2554 raised a pr please review

ShreySinha02 avatar Apr 17 '25 23:04 ShreySinha02