Ejemplo n.º 1
0
 /**
  * Performs validation
  *
  * The whole rule chain is executed. Note that the side effect of this
  * method is setting the error message on element if validation fails
  *
  * @return   boolean     Whether the element is valid
  */
 public function validate()
 {
     $globalValid = false;
     $localValid = $this->checkValue($this->owner->getValue());
     foreach ($this->chainedRules as $item) {
         foreach ($item as $multiplier) {
             if (!$localValid) {
                 break;
             }
             $localValid = $localValid && $multiplier->validate();
         }
         $globalValid = $globalValid || $localValid;
         if ($globalValid) {
             break;
         }
         $localValid = true;
     }
     if (!$globalValid && strlen($this->message) && !$this->owner->getError()) {
         $this->owner->setError($this->message);
     }
     return $globalValid;
 }
Ejemplo n.º 2
0
 /**
  * Validates the owner element
  *
  * @return   bool    Whether owner element is valid according to the rule
  * @todo This should be declared abstract after release 0.4.0
  */
 protected function validateOwner()
 {
     $level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_NOTICE;
     trigger_error(get_class($this) . '::checkValue() is deprecated, implement validateOwner() instead', $level);
     return $this->checkValue($this->owner->getValue());
 }