Skip to content

Commit 6e485a3

Browse files
hammad20120tux-tn
authored andcommitted
fix(isMobilePhone): regex for Pakistan(PK) (#1778)
* 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 <[email protected]> * Update tests for PK phone numbers Co-authored-by: Sarhan Aissi <[email protected]>
1 parent 594ce01 commit 6e485a3

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/lib/isMobilePhone.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const phones = {
4343
'en-MU': /^(\+?230|0)?\d{8}$/,
4444
'en-NG': /^(\+?234|0)?[789]\d{9}$/,
4545
'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
46-
'en-PK': /^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/,
46+
'en-PK': /^((00|\+)?92|0)3[0-6]\d{8}$/,
4747
'en-PH': /^(09|\+639)\d{9}$/,
4848
'en-RW': /^(\+?250|0)?[7]\d{8}$/,
4949
'en-SG': /^(\+65)?[3689]\d{7}$/,

test/validators.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8080,6 +8080,26 @@ describe('Validators', () => {
80808080
'NotANumber',
80818081
],
80828082
},
8083+
{
8084+
locale: 'en-PK',
8085+
valid: [
8086+
'+923412877421',
8087+
'+923001234567',
8088+
'00923001234567',
8089+
'923001234567',
8090+
'03001234567',
8091+
],
8092+
invalid: [
8093+
'+3001234567',
8094+
'+933001234567',
8095+
'+924001234567',
8096+
'+92300123456720',
8097+
'030012345672',
8098+
'30012345673',
8099+
'0030012345673',
8100+
'3001234567',
8101+
],
8102+
},
80838103
];
80848104

80858105
let allValid = [];

0 commit comments

Comments
 (0)