/** * @see ValueValidator::validate() * * @param mixed $value The value to validate * * @return Result */ public function validate($value) { $result = Result::newSuccess(); foreach ($this->validators as $validator) { $subResult = $validator->validate($value); if (!$subResult->isValid()) { if ($this->failFast) { return $subResult; } else { $result = Result::merge($result, $subResult); } } } return $result; }
/** * @see ValueValidator::validate() * * @param mixed $value The value to validate * * @return Result */ public function validate($value) { $result = null; foreach ($this->validators as $validator) { $subResult = $validator->validate($value); if ($subResult->isValid()) { return $subResult; } else { $result = $result ? Result::merge($result, $subResult) : $subResult; } } if (!$result) { $result = Result::newError(array(Error::newError("No validators", null, 'no-validators'))); } return $result; }