From ff1e91eb8b68f0cba8b77b8c84d1ee9334b2453e Mon Sep 17 00:00:00 2001 From: Megan Dolan Date: Sat, 23 Oct 2021 14:02:56 -0500 Subject: [PATCH] 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. --- src/lib/isMobilePhone.js | 2 +- test/validators.js | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index 9607edcc2..cb6613421 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -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}$/, diff --git a/test/validators.js b/test/validators.js index b8fc8b4bc..855540668 100644 --- a/test/validators.js +++ b/test/validators.js @@ -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', ], }, {