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); } }