Repository: validatorjs/validator.js
Pull request #2556 (2025-04-20 15:40:45)

Add Qatar phone number validation
- Updated phone object in isMobilePhone validator adding ar-QA regex
- Added isMobilePhone.test.js with Qatar phone number tests

## Checklist

- [ ] PR contains only changes related; no stray files, etc.
- [ ] Tests written


codecov[bot]: ## [Codecov](https://app.codecov.io/gh/validatorjs/validator.js/pull/2556?dropdown=coverage&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:
> Project coverage is 100.00%. Comparing base [(`d07eae6`)](https://app.codecov.io/gh/validatorjs/validator.js/commit/d07eae6cdaf49af6a44b0731b00b0de9827c8019?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs) to head [(`6b05e68`)](https://app.codecov.io/gh/validatorjs/validator.js/commit/6b05e680a823df43a7e851f23b44da5eec901a24?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs).

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


```diff
@@            Coverage Diff            @@
##            master     #2556   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2535      2536    +1     
  Branches       641       641           
=========================================
+ Hits          2535      2536    +1     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/validatorjs/validator.js/pull/2556?dropdown=coverage&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).

<details><summary> :rocket: New features to boost your workflow: </summary>

- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>

Patch:
diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js
index ec1483d..b00391e 100644
--- a/src/lib/isMobilePhone.js
+++ b/src/lib/isMobilePhone.js
@@ -20,6 +20,7 @@ const phones = {
   'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/,
   'ar-TN': /^(\+?216)?[2459]\d{7}$/,
   'az-AZ': /^(\+994|0)(10|5[015]|7[07]|99)\d{7}$/,
+  'ar-QA': /^(\+?974|0)?([3567]\d{7})$/,
   'bs-BA': /^((((\+|00)3876)|06))((([0-3]|[5-6])\d{6})|(4\d{7}))$/,
   'be-BY': /^(\+?375)?(24|25|29|33|44)\d{7}$/,
   'bg-BG': /^(\+?359|0)?8[789]\d{7}$/,


Test patch:
diff --git a/test/validators.test.js b/test/validators.test.js
index 7c8c495..299af27 100644
--- a/test/validators.test.js
+++ b/test/validators.test.js
@@ -10688,6 +10688,11 @@ describe('Validators', () => {
           '80912345',
         ],
       },
+      {
+        locale: 'ar-QA',
+        valid: ['+97435551234', '+97455551234', '+97465551234', '+97475551234', '35551234', '55551234', '65551234', '75551234'],
+        invalid: ['+97445551234', '+97405551234', '+9745555123', '+974555512345', '+97355551234', '+9125551234', '25551234', '+13005551234', '45551234', '95551234', '+9745555abcd', '', '+974'],
+      },
     ];
 
     let allValid = [];