Exemplo n.º 1
0
 /**
  * Delegate validation to wrapped validator
  *
  * @param mixed $value
  * @return boolean
  * @api
  */
 public function isValid($value)
 {
     $result = true;
     $this->_clearMessages();
     if (!$this->_wrappedValidator->isValid($this->_getValidatorValue($value))) {
         $this->_addMessages($this->_wrappedValidator->getMessages());
         $result = false;
     }
     return $result;
 }
 public function aroundIsAttributeValid(ValidatorInterface $subject, \Closure $proceed, $attrCode, array $attrParams, array $rowData)
 {
     $result = $proceed($attrCode, $attrParams, $rowData);
     if ($result === false) {
         $messages = (array) $subject->getMessages();
         switch (end($messages)) {
             case RowValidatorInterface::ERROR_INVALID_ATTRIBUTE_TYPE:
                 $this->addAdditionalMessage(sprintf('[SKU %s] %s value for attribute "%s" expected. Your input: "%s"', $rowData['sku'], ucfirst($attrParams['type']), $attrCode, $rowData[$attrCode]));
                 break;
         }
     }
     return $result;
 }