From e7d688ab9956d34e2f1cf4c6235c85b60aac59f2 Mon Sep 17 00:00:00 2001 From: Vincent Marmiesse Date: Fri, 12 Dec 2025 15:25:03 +0100 Subject: [PATCH] Fix #40361 - Customer address telephone validation does not work if there is no allowed characters --- .../Magento/Customer/Model/Validator/Telephone.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Customer/Model/Validator/Telephone.php b/app/code/Magento/Customer/Model/Validator/Telephone.php index 620d734e9b2c8..d3e477a0cd3e2 100644 --- a/app/code/Magento/Customer/Model/Validator/Telephone.php +++ b/app/code/Magento/Customer/Model/Validator/Telephone.php @@ -24,7 +24,7 @@ class Telephone extends AbstractValidator * \d: Digits (0-9). */ private const PATTERN_TELEPHONE = '/(?:[\d\s\+\-\()]{1,20})/u'; - + /** * Validate telephone fields. * @@ -50,12 +50,10 @@ public function isValid($customer) */ private function isValidTelephone($telephoneValue) { - if ($telephoneValue != null) { - if (preg_match(self::PATTERN_TELEPHONE, (string) $telephoneValue, $matches)) { - return $matches[0] == $telephoneValue; - } + if ($telephoneValue === null) { + return true; } - return true; + return (bool) preg_match(self::PATTERN_TELEPHONE, (string) $telephoneValue); } }