From ccd46476cf5de3265e012dd2c223e6f5666eb13f Mon Sep 17 00:00:00 2001 From: Eshwar Date: Thu, 21 Nov 2024 23:15:16 +0530 Subject: [PATCH] fix:refined regex for all mk numbers --- src/lib/isMobilePhone.js | 2 +- test/validators.test.js | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index a04028bc0..477979703 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -160,7 +160,7 @@ const phones = { 'ar-YE': /^(((\+|00)9677|0?7)[0137]\d{7}|((\+|00)967|0)[1-7]\d{6})$/, 'ar-EH': /^(\+?212|0)[\s\-]?(5288|5289)[\s\-]?\d{5}$/, 'fa-AF': /^(\+93|0)?(2{1}[0-8]{1}|[3-5]{1}[0-4]{1})(\d{7})$/, - 'mk-MK': /^(\+?389|0)?[2-8]\d{7}$/, + '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}))$/, }; /* eslint-enable max-len */ diff --git a/test/validators.test.js b/test/validators.test.js index 48a1ac69a..3f1053ef6 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -10733,24 +10733,29 @@ describe('Validators', () => { { locale: 'mk-MK', valid: [ - '+38921234567', - '+38971234567', + '+38923234567', '38931234567', - '38961234567', - '21234567', + '022123456', + '22234567', '71234567', '31234567', '+38923091500', + '80091234', + '81123456', + '54123456', ], invalid: [ '38912345678', '+389123456789', - '2123456', + '21234567', '123456789', '+3891234567', + '700012345', + '510123456', 'This should fail', '+389123456', '389123456', + '80912345', ], }, ];