Skip to content

Improve address save flow to allow to use custom validators #7552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions app/code/Magento/Customer/Model/Address/AbstractAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -562,23 +562,23 @@ public function validate()
{
$errors = [];
if (!\Zend_Validate::is($this->getFirstname(), 'NotEmpty')) {
$errors[] = __('Please enter the first name.');
$errors[] = __('%fieldName is a required field.', ['fieldName' => 'firstname']);
}

if (!\Zend_Validate::is($this->getLastname(), 'NotEmpty')) {
$errors[] = __('Please enter the last name.');
$errors[] = __('%fieldName is a required field.', ['fieldName' => 'lastname']);
}

if (!\Zend_Validate::is($this->getStreetLine(1), 'NotEmpty')) {
$errors[] = __('Please enter the street.');
$errors[] = __('%fieldName is a required field.', ['fieldName' => 'street']);
}

if (!\Zend_Validate::is($this->getCity(), 'NotEmpty')) {
$errors[] = __('Please enter the city.');
$errors[] = __('%fieldName is a required field.', ['fieldName' => 'city']);
}

if (!\Zend_Validate::is($this->getTelephone(), 'NotEmpty')) {
$errors[] = __('Please enter the phone number.');
$errors[] = __('%fieldName is a required field.', ['fieldName' => 'telephone']);
}

$_havingOptionalZip = $this->_directoryData->getCountriesWithOptionalZip();
Expand All @@ -590,11 +590,11 @@ public function validate()
'NotEmpty'
)
) {
$errors[] = __('Please enter the zip/postal code.');
$errors[] = __('%fieldName is a required field.', ['fieldName' => 'postcode']);
}

if (!\Zend_Validate::is($this->getCountryId(), 'NotEmpty')) {
$errors[] = __('Please enter the country.');
$errors[] = __('%fieldName is a required field.', ['fieldName' => 'countryId']);
}

if ($this->getCountryModel()->getRegionCollection()->getSize() && !\Zend_Validate::is(
Expand All @@ -604,7 +604,7 @@ public function validate()
$this->getCountryId()
)
) {
$errors[] = __('Please enter the state/province.');
$errors[] = __('%fieldName is a required field.', ['fieldName' => 'regionId']);
}

if (empty($errors) || $this->getShouldIgnoreValidation()) {
Expand Down