Skip to content

Commit 050a424

Browse files
hammad20120tux-tn
andauthored
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 9347d6d commit 050a424

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
@@ -8056,6 +8056,26 @@ describe('Validators', () => {
80568056
'NotANumber',
80578057
],
80588058
},
8059+
{
8060+
locale: 'en-PK',
8061+
valid: [
8062+
'+923412877421',
8063+
'+923001234567',
8064+
'00923001234567',
8065+
'923001234567',
8066+
'03001234567',
8067+
],
8068+
invalid: [
8069+
'+3001234567',
8070+
'+933001234567',
8071+
'+924001234567',
8072+
'+92300123456720',
8073+
'030012345672',
8074+
'30012345673',
8075+
'0030012345673',
8076+
'3001234567',
8077+
],
8078+
},
80598079
];
80608080

80618081
let allValid = [];

0 commit comments

Comments
 (0)