From ca6fb5e3a7e01be1e4264bc6d0b96f38571701fa Mon Sep 17 00:00:00 2001 From: Krzysztof Jamroz Date: Sat, 7 Dec 2024 23:33:24 +0100 Subject: [PATCH] Fix: Update regex for validating Israeli (he-IL) mobile number (#2503) --- src/lib/isMobilePhone.js | 2 +- test/validators.test.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index 393ee6fbd..43893821e 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -108,7 +108,7 @@ const phones = { 'fr-PF': /^(\+?689)?8[789]\d{6}$/, 'fr-RE': /^(\+?262|0|00262)[67]\d{8}$/, 'fr-WF': /^(\+681)?\d{6}$/, - 'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/, + 'he-IL': /^(\+972|0)([23489]|5[012345689]|7[12345679])[1-9]\d{6}$/, 'hu-HU': /^(\+?36|06)(20|30|31|50|70)\d{7}$/, 'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/, 'ir-IR': /^(\+98|0)?9\d{9}$/, diff --git a/test/validators.test.js b/test/validators.test.js index aa13906b0..94d27656c 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -10819,6 +10819,34 @@ describe('Validators', () => { args: [], }); + // he-IL non-Geographic + test({ + validator: 'isMobilePhone', + valid: [ + '+972718742400', + '+972722634352', + '+972723727704', + '+972732934633', + '+972733063541', + '+972737177616', + '+972747724838', + '+972765827274', + '+972768818873', + '+972771999972', + '+972792230168', + '+972793209243', + '+972795090837', + '+972796780768', + '+972797614164', + '+972798860797', + '+972799067720', + ], + invalid: [ + '+972700067720', + '+972781067720', + ], + args: [], + }); it('should error on invalid locale', () => { test({