directoryHelper = $directoryHelper; parent::__construct( $localeDate, $logger, $attribute, $localeResolver, $value, $entityTypeCode, $isAjax ); } /** * Validate postal/zip code * Return true and skip validation if country zip code is optional * * @param array|null|string $value * @return array|bool */ public function validateValue($value) { $attribute = $this->getAttribute(); $label = __($attribute->getStoreLabel()); $countryId = $this->getExtractedData('country_id'); if ($this->directoryHelper->isZipCodeOptional($countryId)) { return true; } $errors = []; if (empty($value) && $value !== '0') { $errors[] = __('"%1" is a required value.', $label); } if (count($errors) == 0) { return true; } return $errors; } /** * {@inheritdoc} */ public function extractValue(\Magento\Framework\App\RequestInterface $request) { return $this->_applyInputFilter($this->_getRequestValue($request)); } /** * {@inheritdoc} */ public function compactValue($value) { return $value; } /** * {@inheritdoc} */ public function restoreValue($value) { return $this->compactValue($value); } /** * {@inheritdoc} */ public function outputValue($format = ElementFactory::OUTPUT_FORMAT_TEXT) { return $this->_applyOutputFilter($this->_value); } }