/** * 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; }
/** * Sets the error message on the owner element */ protected function setOwnerError() { if (strlen($this->getMessage()) && !$this->owner->getError()) { $this->owner->setError($this->getMessage()); } }