Skip to content

Commit b33aab9

Browse files
author
Mohan Ahuja
committed
ACP2E-1001: Customer Zip Code input validation rule not working
- Fixing build failures.
1 parent 06688ec commit b33aab9

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

app/code/Magento/Customer/Model/Metadata/Form.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ class Form
1919
/**#@+
2020
* Values for ignoreInvisible parameter in constructor
2121
*/
22-
const IGNORE_INVISIBLE = true;
22+
public const IGNORE_INVISIBLE = true;
2323

24-
const DONT_IGNORE_INVISIBLE = false;
24+
public const DONT_IGNORE_INVISIBLE = false;
2525

26-
/**#@-*/
27-
28-
/**#@-*/
26+
/**
27+
* @var CustomerMetadataInterface
28+
*/
2929
protected $_customerMetadataService;
3030

3131
/**
@@ -64,8 +64,6 @@ class Form
6464
protected $_isAjax = false;
6565

6666
/**
67-
* Attribute values
68-
*
6967
* @var array
7068
*/
7169
protected $_attributeValues = [];
@@ -365,9 +363,9 @@ public function validateData(array $data)
365363
if (!$validator->isValid(false)) {
366364
$messages = [];
367365
foreach ($validator->getMessages() as $errorMessages) {
368-
$messages = array_merge($messages, array_values((array)$errorMessages));
366+
$messages[] = array_values((array)$errorMessages);
369367
}
370-
return $messages;
368+
return array_merge([], ...$messages);
371369
}
372370
return true;
373371
}

app/code/Magento/Customer/Model/Metadata/Form/Postcode.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Customer\Model\Metadata\ElementFactory;
1010
use Magento\Directory\Helper\Data as DirectoryHelper;
1111
use Magento\Framework\Api\ArrayObjectSearch;
12+
use Magento\Framework\Stdlib\StringUtils;
1213
use Magento\Framework\Locale\ResolverInterface;
1314
use Psr\Log\LoggerInterface as PsrLogger;
1415
use Magento\Framework\Stdlib\DateTime\TimezoneInterface as MagentoTimezone;
@@ -24,7 +25,7 @@ class Postcode extends AbstractData
2425
protected $directoryHelper;
2526

2627
/**
27-
* @var \Magento\Framework\Stdlib\StringUtils
28+
* @var StringUtils
2829
*/
2930
protected $_string;
3031

@@ -37,7 +38,7 @@ class Postcode extends AbstractData
3738
* @param string $entityTypeCode
3839
* @param bool $isAjax
3940
* @param DirectoryHelper $directoryHelper
40-
* @param \Magento\Framework\Stdlib\StringUtils $stringHelper
41+
* @param StringUtils|null $stringHelper
4142
*/
4243
public function __construct(
4344
MagentoTimezone $localeDate,
@@ -48,9 +49,12 @@ public function __construct(
4849
$entityTypeCode,
4950
$isAjax,
5051
DirectoryHelper $directoryHelper,
51-
\Magento\Framework\Stdlib\StringUtils $stringHelper
52+
StringUtils $stringHelper = null
5253
) {
5354
$this->directoryHelper = $directoryHelper;
55+
if (is_null($stringHelper)) {
56+
$stringHelper = \Magento\Framework\App\ObjectManager::getInstance()->get(StringUtils::class);
57+
}
5458
$this->_string = $stringHelper;
5559
parent::__construct(
5660
$localeDate,
@@ -65,6 +69,7 @@ public function __construct(
6569

6670
/**
6771
* Validate postal/zip code
72+
*
6873
* Return true and skip validation if country zip code is optional
6974
*
7075
* @param array|null|string $value
@@ -99,31 +104,31 @@ public function validateValue($value)
99104
}
100105

101106
/**
102-
* {@inheritdoc}
107+
* @inheritdoc
103108
*/
104109
public function extractValue(\Magento\Framework\App\RequestInterface $request)
105110
{
106111
return $this->_applyInputFilter($this->_getRequestValue($request));
107112
}
108113

109114
/**
110-
* {@inheritdoc}
115+
* @inheritdoc
111116
*/
112117
public function compactValue($value)
113118
{
114119
return $value;
115120
}
116121

117122
/**
118-
* {@inheritdoc}
123+
* @inheritdoc
119124
*/
120125
public function restoreValue($value)
121126
{
122127
return $this->compactValue($value);
123128
}
124129

125130
/**
126-
* {@inheritdoc}
131+
* @inheritdoc
127132
*/
128133
public function outputValue($format = ElementFactory::OUTPUT_FORMAT_TEXT)
129134
{

0 commit comments

Comments
 (0)