_validators[] = array('instance' => $validator, 'breakChainOnFailure' => $breakChainOnFailure); return $this; } /** * Returns true if and only if $value passes all validations in the chain * * Validators are run in the order in which they were added to the chain (FIFO). * * @param mixed $value * @return boolean */ public function isValid($value) { $this->_messages = array(); $result = true; foreach ($this->_validators as $element) { $validator = $element['instance']; if ($validator->isValid($value)) { continue; } $result = false; $this->_messages = $this->_messages + $validator->getMessages(); if ($element['breakChainOnFailure']) { break; } } return $result; } /** * Defined by Zend_Validate_Interface * * Returns array of validation failure messages * * @return array */ public function getMessages() { return $this->_messages; } }