Skip to content

Commit

Permalink
Add 'min_fail_severity' param on 'And' validator
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHash committed Jul 30, 2015
1 parent b9eebd6 commit bf6af7b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/validator/AgaviAndoperatorValidator.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* Parameters:
* 'skip_errors' do not submit errors of child validators to validator manager
* 'break' break the execution of child validators after first failure
* 'min_fail_severity' minimum child validator severity level to fail on
*
* @package agavi
* @subpackage validator
Expand Down Expand Up @@ -47,10 +48,15 @@ protected function validate()
{
$return = true;

$min_fail_severity = $this->getParameter('min_fail_severity', AgaviValidator::INFO);
if(strpos($min_fail_severity, '::') && defined($min_fail_severity)) {
$min_fail_severity = constant($min_fail_severity);
}

foreach($this->children as $child) {
$result = $child->execute($this->validationParameters);
$this->result = max($result, $this->result);
if($result > AgaviValidator::SUCCESS) {
if($result >= $min_fail_severity) {
// if one validator fails, the whole operator fails
$return = false;
$this->throwError();
Expand All @@ -64,4 +70,4 @@ protected function validate()
}
}

?>
?>

0 comments on commit bf6af7b

Please sign in to comment.