From cd237dc8892b8194ae12077eb8302fdf0bc32bf4 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Mon, 23 Jan 2023 23:07:01 +0100 Subject: [PATCH] fix(isMobilePhone): fix 'ro-RO' matching invalid numbers * fixed the bug that would cause it to match invalid numbers * added tests for invalid numbers fixes #2055 --- src/lib/isMobilePhone.js | 2 +- test/validators.test.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index a5424ff34..a4a46f1f1 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -131,7 +131,7 @@ const phones = { 'pt-BR': /^((\+?55\ ?[1-9]{2}\ ?)|(\+?55\ ?\([1-9]{2}\)\ ?)|(0[1-9]{2}\ ?)|(\([1-9]{2}\)\ ?)|([1-9]{2}\ ?))((\d{4}\-?\d{4})|(9[1-9]{1}\d{3}\-?\d{4}))$/, 'pt-PT': /^(\+?351)?9[1236]\d{7}$/, 'pt-AO': /^(\+244)\d{9}$/, - 'ro-RO': /^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/, + 'ro-RO': /^(\+?40|0)\s?7\d{2}(\/|\s|\.|-)?\d{3}(\s|\.|-)?\d{3}$/, 'ru-RU': /^(\+?7|8)?9\d{9}$/, 'si-LK': /^(?:0|94|\+94)?(7(0|1|2|4|5|6|7|8)( |-)?)\d{7}$/, 'sl-SI': /^(\+386\s?|0)(\d{1}\s?\d{3}\s?\d{2}\s?\d{2}|\d{2}\s?\d{3}\s?\d{3})$/, diff --git a/test/validators.test.js b/test/validators.test.js index 0405a7d2f..6289a51b1 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -8856,6 +8856,8 @@ describe('Validators', () => { '740123456', '+40640123456', '+40210123456', + '+0765351689', + '+0711419752', ], }, {