Пример #1
0
 /**
  * (non-PHPdoc)
  * @see \Simplify\Form\Element::onValidate()
  */
 public function onValidate(\Simplify\Form\Action $action, $data)
 {
     parent::onValidate($action, $data);
     $required = $action->show($this->required) ? $this->getError('required', __('Campo obrigatório')) : false;
     $invalid = $this->getError('invalid', __('Email inválido'));
     $rule = new \Simplify\Validation\Email($invalid, $required);
     $rule->validate($this->getValue($data));
 }
Пример #2
0
 /**
  * (non-PHPdoc)
  * @see \Simplify\Form\Element::onValidate()
  */
 public function onValidate(\Simplify\Form\Action $action, $data)
 {
     parent::onValidate($action, $data);
     if ($this->required) {
         $rule = new \Simplify\Validation\StrictEqual('Invalid selection', $this->emptyValue);
         $rule->validate($this->getValue($data));
     }
 }
Пример #3
0
 /**
  * (non-PHPdoc)
  * @see \Simplify\Form\Element::onValidate()
  */
 public function onValidate(\Simplify\Form\Action $action, $data)
 {
     parent::onValidate($action, $data);
     if ($this->minLength !== false || $this->maxLength !== false) {
         if ($this->minLength === $this->maxLength) {
             $msg = _n('%1$s deve ter exatamente %2$s caracteres', '%1$s deve ter exatamente %2$s caracteres', $this->minLength);
         } elseif ($this->minLength !== false) {
             if ($this->maxLength !== false) {
                 $msg = __('%1$s deve ter entre %2$s e %3$s caracteres');
             } else {
                 $msg = __('%1$s deve ter %2$s ou mais caracteres');
             }
         } elseif ($this->maxLength !== false) {
             $msg = __('%1$s deve ter %3$s ou menos caracteres');
         }
         $msg = sprintf($msg, $this->getLabel(), $this->minLength, $this->maxLength);
         $rule = new \Simplify\Validation\Length($msg, $this->minLength, $this->maxLength);
         $rule->validate($this->getValue($data));
     }
 }
Пример #4
0
 /**
  * (non-PHPdoc)
  * @see \Simplify\Form\Element::onValidate()
  */
 public function onValidate(\Simplify\Form\Action $action, $data)
 {
     parent::onValidate($action, $data);
     $rule = new \Simplify\Validation\Callback(array($this, 'validate'));
     $rule->validate($this->getValue($data));
 }