Skip to content

Commit

Permalink
Changed regex for BW
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mgndolan committed Oct 23, 2021
1 parent bb6f0ca commit ff1e91e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lib/isMobilePhone.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,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)\d{7,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
14 changes: 10 additions & 4 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -7838,20 +7838,26 @@ describe('Validators', () => {
{
locale: 'en-BW',
valid: [
'+26754868990',
'+267543687909',
'+2670745605',
'+26772868545',
'+26776368790',
'+26774560512',
'26774560591',
'2670745605',
'26771560512',
'74560512',
'76710284',
],
invalid: [
'0799375902',
'12345',
'+2670745605448',
'2670745605482',
'+26778685451',
'+26770685451',
'267074560',
'2670ab5608',
'+267074560',
'70560512',
'78710284',
],
},
{
Expand Down

0 comments on commit ff1e91e

Please sign in to comment.