Skip to content

Commit 9f0fda6

Browse files
committed
MAGETWO-91465: Once integer is stored for State/Province field, it can not be changed to alphanumeric
1 parent a1031b4 commit 9f0fda6

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

app/code/Magento/Customer/Model/Address/Validator/Country.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ private function validateRegion(AbstractAddress $address)
9595
$countryId = $address->getCountryId();
9696
$countryModel = $address->getCountryModel();
9797
$regionCollection = $countryModel->getRegionCollection();
98-
$region = $address->getRegion();
99-
$regionId = (string)$address->getRegionId();
98+
$region = $address->getData('region');
99+
$regionId = (string)$address->getData('region_id');
100100
$allowedRegions = $regionCollection->getAllIds();
101101
$isRegionRequired = $this->directoryData->isRegionRequired($countryId);
102102
if ($isRegionRequired && empty($allowedRegions) && !\Zend_Validate::is($region, 'NotEmpty')) {
@@ -107,7 +107,7 @@ private function validateRegion(AbstractAddress $address)
107107
//If country actually has regions and requires you to
108108
//select one then it must be selected.
109109
$errors[] = __('"%fieldName" is required. Enter and try again.', ['fieldName' => 'regionId']);
110-
} elseif ($regionId && !in_array($regionId, $allowedRegions, true)) {
110+
} elseif ($allowedRegions && $regionId && !in_array($regionId, $allowedRegions, true)) {
111111
//If a region is selected then checking if it exists.
112112
$errors[] = __(
113113
'Invalid value of "%value" provided for the %fieldName field.',

app/code/Magento/Customer/Test/Unit/Model/Address/Validator/CountryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function validateDataProvider()
162162
array_merge($data, ['country_id' => $countryId, 'region_id' => 2]),
163163
[$countryId++],
164164
[1],
165-
['Invalid value of "2" provided for the regionId field.'],
165+
[],
166166
],
167167
'validated' => [
168168
array_merge($data, ['country_id' => $countryId]),

0 commit comments

Comments
 (0)