Skip to content

Commit 164d818

Browse files
committed
allow [] in street, allow white space in phone number
1 parent 580dcf1 commit 164d818

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

app/code/Magento/Customer/Model/Validator/Street.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Street extends AbstractValidator
2828
* \s: Whitespace characters (spaces, tabs, newlines, etc.).
2929
* \d: Digits (0-9).
3030
*/
31-
private const PATTERN_STREET = "/(?:[\p{L}\p{M},-.'’`&\s\d]){1,255}+/u";
31+
private const PATTERN_STREET = "/(?:[\p{L}\p{M}\"[],-.'’`&\s\d]){1,255}+/u";
3232

3333
/**
3434
* Validate street fields.

app/code/Magento/Customer/Model/Validator/Telephone.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Telephone extends AbstractValidator
2323
* \-: Matches the hyphen.
2424
* \d: Digits (0-9).
2525
*/
26-
private const PATTERN_TELEPHONE = '/(?:[\d\+\-\()]{1,20})/u';
26+
private const PATTERN_TELEPHONE = '/(?:[\d\s\+\-\()]{1,20})/u';
2727

2828
/**
2929
* Validate telephone fields.
@@ -35,7 +35,7 @@ public function isValid($customer)
3535
{
3636
if (!$this->isValidTelephone($customer->getTelephone())) {
3737
parent::_addMessages([[
38-
'telephone' => "Invalid Phone Number. Please use 0-9, +, -, (, ). space not allowed."
38+
'telephone' => "Invalid Phone Number. Please use 0-9, +, -, (, ) and space."
3939
]]);
4040
}
4141

@@ -51,7 +51,7 @@ public function isValid($customer)
5151
private function isValidTelephone($telephoneValue)
5252
{
5353
if ($telephoneValue != null) {
54-
if (preg_match(self::PATTERN_TELEPHONE, $telephoneValue, $matches)) {
54+
if (preg_match(self::PATTERN_TELEPHONE, (string) $telephoneValue, $matches)) {
5555
return $matches[0] == $telephoneValue;
5656
}
5757
}

0 commit comments

Comments
 (0)