Repository: validatorjs/validator.js
Pull request #2350 (2024-01-09 20:03:07)

feat(isMobilePhone): add validation for Kyrgyzstan [ky-KG] mobile phone numbers
<!--- briefly describe what you have done in this PR --->

I have updated the regular expression used for validating mobile phone numbers in the Kyrgyzstan Republic.

<!--- provide some (credible) references showing the structure of the data to be validated, if applicable --->

I have used the following references to structure the updated regular expression:
- [Kyrgyzstan Mobile Phone Number Structure](https://en.wikipedia.org/wiki/Telephone_numbers_in_Kyrgyzstan)

## Checklist

- [x] PR contains only changes related; no stray files, etc.
- [ ] README updated (where applicable)
- [x] Tests written (where applicable)
- [x] References provided in PR (where applicable)


codecov[bot]: ## [Codecov](https://app.codecov.io/gh/validatorjs/validator.js/pull/2350?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Comparison is base [(`b958bd7`)](https://app.codecov.io/gh/validatorjs/validator.js/commit/b958bd7d1026a434ad3bf90064d3dcb8b775f1a9?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs) 99.95% compared to head [(`3899f68`)](https://app.codecov.io/gh/validatorjs/validator.js/pull/2350?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs) 99.95%.


<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #2350      +/-   ##
==========================================
- Coverage   99.95%   99.95%   -0.01%     
==========================================
  Files         107      107              
  Lines        2454     2449       -5     
  Branches      619      619              
==========================================
- Hits         2453     2448       -5     
  Partials        1        1              
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/validatorjs/validator.js/pull/2350?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs).


Patch:
diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js
index e5fb6bf..e9932ca 100644
--- a/src/lib/isMobilePhone.js
+++ b/src/lib/isMobilePhone.js
@@ -119,7 +119,7 @@ const phones = {
   'kk-KZ': /^(\+?7|8)?7\d{9}$/,
   'kl-GL': /^(\+?299)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
   'ko-KR': /^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/,
-  'ky-KG': /^(\+?7\s?\+?7|0)\s?\d{2}\s?\d{3}\s?\d{4}$/,
+  'ky-KG': /^(\+996\s?)?(22[0-9]|50[0-9]|55[0-9]|70[0-9]|75[0-9]|77[0-9]|880|990|995|996|997|998)\s?\d{3}\s?\d{3}$/,
   'lt-LT': /^(\+370|8)\d{8}$/,
   'lv-LV': /^(\+?371)2\d{7}$/,
   'mg-MG': /^((\+?261|0)(2|3)\d)?\d{7}$/,


Test patch:
diff --git a/test/validators.test.js b/test/validators.test.js
index 3b6ede6..31a36d0 100644
--- a/test/validators.test.js
+++ b/test/validators.test.js
@@ -9536,15 +9536,44 @@ describe('Validators', () => {
       {
         locale: 'ky-KG',
         valid: [
-          '+7 727 123 4567',
-          '+7 714 2396102',
-          '77271234567',
-          '0271234567',
-        ],
-        invalid: [
-          '02188565377',
-          '09386932778',
-          '0938693277vadggjdsaasdgj8',
+          '+996553033300',
+          '+996 222 123456',
+          '+996 500 987654',
+          '+996 555 111222',
+          '+996 700 333444',
+          '+996 770 555666',
+          '+996 880 777888',
+          '+996 990 999000',
+          '+996 995 555666',
+          '+996 996 555666',
+          '+996 997 555666',
+          '+996 998 555666',
+        ],
+        invalid: [
+          '+996 201 123456',
+          '+996 312 123456',
+          '+996 3960 12345',
+          '+996 3961 12345',
+          '+996 3962 12345',
+          '+996 3963 12345',
+          '+996 3964 12345',
+          '+996 3965 12345',
+          '+996 3966 12345',
+          '+996 3967 12345',
+          '+996 3968 12345',
+          '+996 511 123456',
+          '+996 522 123456',
+          '+996 561 123456',
+          '+996 571 123456',
+          '+996 624 123456',
+          '+996 623 123456',
+          '+996 622 123456',
+          '+996 609 123456',
+          '+996 100 12345',
+          '+996 100 1234567',
+          '996 100 123456',
+          '0 100 123456',
+          '0 100 123abc',
         ],
       },
       {