Skip to content

Commit

Permalink
feat(isMobilePhone): add Botswana en-BW locale
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
mgndolan authored and profnandaa committed Oct 31, 2021
1 parent 26605f9 commit a3faa83
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/isMobilePhone.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const phones = {
'en-ZA': /^(\+?27|0)\d{9}$/,
'en-ZM': /^(\+?26)?09[567]\d{7}$/,
'en-ZW': /^(\+263)[0-9]{9}$/,
'en-BW': /^(\+?267)?(7[1-8]{1})\d{6}$/,
'es-AR': /^\+?549(11|[2368]\d)\d{8}$/,
'es-BO': /^(\+?591)?(6|7)\d{7}$/,
'es-CO': /^(\+?57)?3(0(0|1|2|4|5)|1\d|2[0-4]|5(0|1))\d{7}$/,
Expand Down
25 changes: 25 additions & 0 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -8261,6 +8261,31 @@ describe('Validators', () => {
'23274560591 ',
],
},
{
locale: 'en-BW',
valid: [
'+26772868545',
'+26776368790',
'+26774560512',
'26774560591',
'26778560512',
'74560512',
'76710284',
],
invalid: [
'0799375902',
'12345',
'+2670745605448',
'2670745605482',
'+26779685451',
'+26770685451',
'267074560',
'2670ab5608',
'+267074560',
'70560512',
'79710284',
],
},
{
locale: 'az-AZ',
valid: [
Expand Down

0 comments on commit a3faa83

Please sign in to comment.