Repository: validatorjs/validator.js
Pull request #1971 (2022-05-18 08:05:09)

feat(isMobilePhone): en-GB enhance
<!--
Add a descriptive title textbox above, e.g.
feat(validatorName): brief title of what has been done
-->

<!--- briefly describe what you have done in this PR --->
Update mobile phone validation for `en-GB`

- The first digit after `07` should not be zero
- Updated tests

## Checklist

- [x] PR contains only changes related; no stray files, etc.
- [x] README updated (where applicable)
- [x] Tests written (where applicable)

Inspired by https://github.com/validatorjs/validator.js/pull/1164

Also I am wondering, whether support more phone numbers in the UK. 

Quorra link with explanation https://qr.ae/pvAeI7 

codecov[bot]: # [Codecov](https://codecov.io/gh/validatorjs/validator.js/pull/1971?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs) Report
> Merging [#1971](https://codecov.io/gh/validatorjs/validator.js/pull/1971?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs) (8f6c21b) into [master](https://codecov.io/gh/validatorjs/validator.js/commit/cfcf9113c69b97477c409909a8729fa8efa0d595?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs) (cfcf911) will **not change** coverage.
> The diff coverage is `n/a`.

```diff
@@            Coverage Diff            @@
##            master     #1971   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          103       103           
  Lines         2097      2097           
  Branches       473       473           
=========================================
  Hits          2097      2097           
```


| [Impacted Files](https://codecov.io/gh/validatorjs/validator.js/pull/1971?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs) | Coverage Δ | |
|---|---|---|
| [src/lib/isMobilePhone.js](https://codecov.io/gh/validatorjs/validator.js/pull/1971/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs#diff-c3JjL2xpYi9pc01vYmlsZVBob25lLmpz) | `100.00% <ø> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/validatorjs/validator.js/pull/1971?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/validatorjs/validator.js/pull/1971?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs). Last update [cfcf911...8f6c21b](https://codecov.io/gh/validatorjs/validator.js/pull/1971?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs).

profnandaa: @ihmpavel - possible to fix the merge conflict here? Should be okay to land after that.
rubiin: @ihmpavel can you fix the merge conflicts
ihmpavel: @rubiin Conflicts resolved
ihmpavel: It looks like `mc-to-land` label is redundant 
profnandaa: @ihmpavel -- we use it as maintainers to quickly scan through PRs are good but just need merge conflict resolutions. Sometimes we go ahead to resolve the conflicts ourselves when the authors are a bit unresponsive.

Patch:
diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js
index 4d81921..72af200 100644
--- a/src/lib/isMobilePhone.js
+++ b/src/lib/isMobilePhone.js
@@ -39,7 +39,7 @@ const phones = {
   'en-AG': /^(?:\+1|1)268(?:464|7(?:1[3-9]|[28]\d|3[0246]|64|7[0-689]))\d{4}$/,
   'en-BM': /^(\+?1)?441(((3|7)\d{6}$)|(5[0-3][0-9]\d{4}$)|(59\d{5}$))/,
   'en-BS': /^(\+?1[-\s]?|0)?\(?242\)?[-\s]?\d{3}[-\s]?\d{4}$/,
-  'en-GB': /^(\+?44|0)7\d{9}$/,
+  'en-GB': /^(\+?44|0)7[1-9]\d{8}$/,
   'en-GG': /^(\+?44|0)1481\d{6}$/,
   'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28|55|59)\d{7}$/,
   'en-GY': /^(\+592|0)6\d{6}$/,


Test patch:
diff --git a/test/validators.test.js b/test/validators.test.js
index 6b603ff..72dd29a 100644
--- a/test/validators.test.js
+++ b/test/validators.test.js
@@ -8221,6 +8221,9 @@ describe('Validators', () => {
           '+443003434751',
           '05073456754',
           '08001123123',
+          '07043425232',
+          '01273884231',
+          '03332654034',
         ],
       },
       {