Skip to content

Commit 85dc594

Browse files
author
hammadparveez
committed
fix(isMobilePhone): correct fa-AF regex to match Afghan mobile numbers
The previous regex matched Afghan landline numbers (prefix 2x/5x) instead of mobile numbers. Afghan mobile numbers use the 7x prefix (70-79) per ITU-T E.164, covering operators AWCC (70x), Salaam (71x), MTN (77x), Etisalat (78x), and Roshan (79x). Updated test cases to use real Afghan mobile number examples. Closes #1761
1 parent 88e0d3d commit 85dc594

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/lib/isMobilePhone.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ const phones = {
160160
'dz-BT': /^(\+?975|0)?(17|16|77|02)\d{6}$/,
161161
'ar-YE': /^(((\+|00)9677|0?7)[0137]\d{7}|((\+|00)967|0)[1-7]\d{6})$/,
162162
'ar-EH': /^(\+?212|0)[\s\-]?(5288|5289)[\s\-]?\d{5}$/,
163-
'fa-AF': /^(\+93|0)?(2{1}[0-8]{1}|[3-5]{1}[0-4]{1})(\d{7})$/,
163+
'fa-AF': /^(\+?93|0)?7[0-9]\d{7}$/,
164164
'mk-MK': /^(\+?389|0)?((?:2[2-9]\d{6}|(?:3[1-4]|4[2-8])\d{6}|500\d{5}|5[2-9]\d{6}|7[0-9][2-9]\d{5}|8[1-9]\d{6}|800\d{5}|8009\d{4}))$/,
165165
};
166166
/* eslint-enable max-len */

test/validators.test.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10946,20 +10946,22 @@ describe('Validators', () => {
1094610946
{
1094710947
locale: 'fa-AF',
1094810948
valid: [
10949-
'0511231231',
10950-
'+93511231231',
10951-
'+93281234567',
10949+
'+93701234567',
10950+
'+93771234567',
10951+
'+93791234567',
10952+
'0701234567',
10953+
'0771234567',
10954+
'701234567',
1095210955
],
1095310956
invalid: [
10954-
'212528812312123',
10955-
'+212-5290-12312',
10956-
'++212528812312',
10957+
'+93201234567',
10958+
'0511231231',
10959+
'+93511231231',
1095710960
'12345',
1095810961
'Afghanistan',
1095910962
'this should fail',
10960-
'212 5288---12312',
10961-
'+503 1111 1111',
10962-
'00 +503 1234 5678',
10963+
'++93701234567',
10964+
'00 +93 701 234 567',
1096310965
],
1096410966
},
1096510967
{

0 commit comments

Comments
 (0)