Validator(); $this->_elementRules = array(); $this->addRule(new ArrayRule()); } /** * Adds a rule to the ArrayValidator to validate the array element * * @param rule A valid Rule object */ function addElementRule(&$rule) { $this->_elementRules[] = &$rule; } /** * ArrayValidator's own validate, it will validate the array itself first, then * validate each element. * * @param values The array that we're going to validate. */ function validate($values) { $validateOk = parent::validate($values); if( !$validateOk ) return false; foreach( $values as $value ) { foreach ($this->_elementRules as $rule) { if (!$rule->validate($value)) { $this->_setError($rule->getError()); return false; } } } return true; } } ?>