10 use Magento\Directory\Model\CountryFactory;
24 'parent_id' =>
'Parent Order Id',
25 'postcode' =>
'Zip code',
26 'lastname' =>
'Last name',
30 'country_id' =>
'Country',
31 'firstname' =>
'First Name',
32 'address_type' =>
'Address Type',
63 ->get(EavConfig::class);
66 $this->required[
'telephone'] =
'Phone Number';
70 $this->required[
'company'] =
'Company';
74 $this->required[
'fax'] =
'Fax';
88 $warnings[] = sprintf(
'"%s" is required. Enter and try again.',
$label);
91 if (!filter_var(
$address->getEmail(), FILTER_VALIDATE_EMAIL)) {
92 $warnings[] =
'Email has a wrong format';
95 $warnings[] =
'Address type doesn\'t match required options';
111 if (
$address->getShouldIgnoreValidation()) {
118 $errors[] =
__(
'Please enter the first name.');
121 $errors[] =
__(
'Please enter the last name.');
124 $errors[] =
__(
'Please enter the street.');
127 $errors[] =
__(
'Please enter the city.');
132 $errors[] =
__(
'Please enter the phone number.');
138 $errors[] =
__(
'Please enter the company.');
144 $errors[] =
__(
'Please enter the fax number.');
148 $countryId =
$address->getCountryId();
151 $errors[] =
__(
'Please enter the zip/postal code.');
153 if ($this->
isEmpty($countryId)) {
154 $errors[] =
__(
'Please enter the country.');
157 $errors[] =
__(
'Please enter the state/province.');
182 return !in_array($countryId, $this->directoryHelper->getCountriesWithOptionalZip());
193 $country = $this->countryFactory->create()->load($countryId);
194 return $this->directoryHelper->isRegionRequired($countryId) && $country->getRegionCollection()->getSize();
202 return ($this->eavConfig->getAttribute(
'customer_address',
'telephone')->getIsRequired());
210 return ($this->eavConfig->getAttribute(
'customer_address',
'company')->getIsRequired());
218 return ($this->eavConfig->getAttribute(
'customer_address',
'fax')->getIsRequired());
isZipRequired($countryId)
validateForCustomer(Address $address)
isStateRequired($countryId)
__construct(DirectoryHelper $directoryHelper, CountryFactory $countryFactory, EavConfig $eavConfig=null)
validate(Address $address)