Exemple #1
0
 /**
  * Validate postal/zip code
  * Return true and skip validation if country zip code is optional
  *
  * @param array|string $value
  * @return boolean|array
  */
 public function validateValue($value)
 {
     $countryId = $this->getExtractedData('country_id');
     $optionalZip = Mage::helper('directory')->getCountriesWithOptionalZip();
     if (!in_array($countryId, $optionalZip)) {
         return parent::validateValue($value);
     }
     return true;
 }
Exemple #2
0
 /**
  * Export attribute value to entity model
  *
  * @param Mage_Core_Model_Abstract $entity
  * @param array|string $value
  * @return Mage_Eav_Model_Attribute_Data_Multiline
  */
 public function compactValue($value)
 {
     if (is_array($value)) {
         $value = trim(implode("\n", $value));
     }
     return parent::compactValue($value);
 }
Exemple #3
0
 /**
  * @dataProvider validateValueDataProvider
  * @param mixed $inputValue
  * @param mixed $expectedResult
  */
 public function testValidateValue($inputValue, $expectedResult)
 {
     $this->assertEquals($expectedResult, $this->_model->validateValue($inputValue));
 }