Skip to content

Commit a3faa83

Browse files
mgndolanprofnandaa
authored andcommitted
feat(isMobilePhone): add Botswana en-BW locale
Added new condition for Botswana New regex for Botswana numbers Phone number information was found from the following sources: - https://www.howtocallabroad.com/botswana/ - https://countrycode.org/botswana Updated README.md to include en-BW Included the new case for Botswana (en-BW) Added test cases for isMobilePhone en-BW Added some test cases to check length for the phone number & area code pattern. Changed regex for BW Fixed the pattern for Botswana mobile phone numbers and edited the test cases. I followed the convention from Table 8 of the national numbering plan document and the mobile number pattern on the Wiki page. Update validators.js Oops! Looks like the file didn't update with some of my modified test cases - my apologies!
1 parent 26605f9 commit a3faa83

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/lib/isMobilePhone.js

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const phones = {
5959
'en-ZA': /^(\+?27|0)\d{9}$/,
6060
'en-ZM': /^(\+?26)?09[567]\d{7}$/,
6161
'en-ZW': /^(\+263)[0-9]{9}$/,
62+
'en-BW': /^(\+?267)?(7[1-8]{1})\d{6}$/,
6263
'es-AR': /^\+?549(11|[2368]\d)\d{8}$/,
6364
'es-BO': /^(\+?591)?(6|7)\d{7}$/,
6465
'es-CO': /^(\+?57)?3(0(0|1|2|4|5)|1\d|2[0-4]|5(0|1))\d{7}$/,

test/validators.js

+25
Original file line numberDiff line numberDiff line change
@@ -8261,6 +8261,31 @@ describe('Validators', () => {
82618261
'23274560591 ',
82628262
],
82638263
},
8264+
{
8265+
locale: 'en-BW',
8266+
valid: [
8267+
'+26772868545',
8268+
'+26776368790',
8269+
'+26774560512',
8270+
'26774560591',
8271+
'26778560512',
8272+
'74560512',
8273+
'76710284',
8274+
],
8275+
invalid: [
8276+
'0799375902',
8277+
'12345',
8278+
'+2670745605448',
8279+
'2670745605482',
8280+
'+26779685451',
8281+
'+26770685451',
8282+
'267074560',
8283+
'2670ab5608',
8284+
'+267074560',
8285+
'70560512',
8286+
'79710284',
8287+
],
8288+
},
82648289
{
82658290
locale: 'az-AZ',
82668291
valid: [

0 commit comments

Comments
 (0)