From 84455553745bbe08c67ab69fb72a1eb09094eabb Mon Sep 17 00:00:00 2001 From: Mathieu Ducrot Date: Mon, 25 Mar 2024 16:41:15 +0100 Subject: [PATCH] Fix Phone Pattern Regex --- src/Utils/RegexUtils.php | 2 +- tests/Validator/Constraints/RegexValidatorTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Utils/RegexUtils.php b/src/Utils/RegexUtils.php index 6b140a0..c3a1a82 100644 --- a/src/Utils/RegexUtils.php +++ b/src/Utils/RegexUtils.php @@ -4,7 +4,7 @@ class RegexUtils { - public const PHONE_PATTERN = '#^(\+[0-9]{2})?[0-9]{10}$#'; + public const PHONE_PATTERN = '#^(\+[0-9]{1})?[0-9]{10}$#'; public const PHONE_MESSAGE = 'phone.regex_error'; public const FAX_MESSAGE = 'fax.regex_error'; diff --git a/tests/Validator/Constraints/RegexValidatorTest.php b/tests/Validator/Constraints/RegexValidatorTest.php index df653ce..79c978d 100644 --- a/tests/Validator/Constraints/RegexValidatorTest.php +++ b/tests/Validator/Constraints/RegexValidatorTest.php @@ -37,7 +37,7 @@ public function validPhoneProvider(): array { return [ 'concatenated number ' => ["0601020304"], - 'number with dial code without space' => ["+330601020304"], + 'number with dial code without space' => ["+33601020304"], ]; } @@ -62,7 +62,7 @@ public function unvalidPhoneProvider(): array 'number with point' => ["06.01.02.03.04"], 'number with separator combination' => ["0601 02-03.04"], 'grouping of digits other than 2' => ["060 102 0304"], - 'missing + for dialing code' => ["330601020304"], + 'missing + for dialing code' => ["33601020304"], 'number with dial code with space' => ["+33 06 01 02 03 04"], ]; }