Skip to content

Commit

Permalink
fix(isMobilePhone): regex for Pakistan(PK) (#1778)
Browse files Browse the repository at this point in the history
* Fix Mobile Phone Regex Pakistan(PK)

Update the regex to validate mobile numbers correctly for Pakistan

* Add tests for mobile number validation locale en-PK (Pakistan)

* Linting fix

* Update src/lib/isMobilePhone.js

Update pakistan mobile regex according to suggestion

Co-authored-by: Sarhan Aissi <tux-tn@users.noreply.github.com>

* Update tests for PK phone numbers

Co-authored-by: Sarhan Aissi <tux-tn@users.noreply.github.com>
  • Loading branch information
2 people authored and profnandaa committed Oct 31, 2021
1 parent 594ce01 commit 6e485a3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/isMobilePhone.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const phones = {
'en-MU': /^(\+?230|0)?\d{8}$/,
'en-NG': /^(\+?234|0)?[789]\d{9}$/,
'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
'en-PK': /^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/,
'en-PK': /^((00|\+)?92|0)3[0-6]\d{8}$/,
'en-PH': /^(09|\+639)\d{9}$/,
'en-RW': /^(\+?250|0)?[7]\d{8}$/,
'en-SG': /^(\+65)?[3689]\d{7}$/,
Expand Down
20 changes: 20 additions & 0 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -8080,6 +8080,26 @@ describe('Validators', () => {
'NotANumber',
],
},
{
locale: 'en-PK',
valid: [
'+923412877421',
'+923001234567',
'00923001234567',
'923001234567',
'03001234567',
],
invalid: [
'+3001234567',
'+933001234567',
'+924001234567',
'+92300123456720',
'030012345672',
'30012345673',
'0030012345673',
'3001234567',
],
},
];

let allValid = [];
Expand Down

0 comments on commit 6e485a3

Please sign in to comment.