diff --git a/vendor/magento/module-customer/Model/Validator/City.php b/vendor/magento/module-customer/Model/Validator/City.php index 0b53551dfd88..85121015383a 100644 --- a/vendor/magento/module-customer/Model/Validator/City.php +++ b/vendor/magento/module-customer/Model/Validator/City.php @@ -1,7 +1,7 @@ isValidCity($customer->getCity())) { parent::_addMessages([[ - 'city' => "Invalid City. Please use A-Z, a-z, 0-9, -, ', spaces" + 'city' => "Invalid City. Please use letters, numbers, spaces, + and the following characters: - _ ' ’ . , & ( ) /" ]]); } @@ -50,12 +59,10 @@ public function isValid($customer) */ private function isValidCity($cityValue) { - if ($cityValue != null) { - if (preg_match(self::PATTERN_CITY, $cityValue, $matches)) { - return $matches[0] == $cityValue; - } + if ($cityValue === null || $cityValue === '') { + return true; } - return true; + return preg_match(self::PATTERN_CITY, $cityValue) === 1; } }