Permalink
Browse files

Adding support for "last" rule in `Validator::check` method

  • Loading branch information...
1 parent 1281928 commit afe30c71a60809a2a18c7c56c2f7bc3d99996628 @vesln vesln committed Aug 7, 2011
Showing with 6 additions and 1 deletion.
  1. +6 −1 util/Validator.php
View
@@ -430,7 +430,8 @@ public static function check(array $values, array $rules, array $options = array
'required' => true,
'skipEmpty' => false,
'format' => 'any',
- 'on' => null
+ 'on' => null,
+ 'last' => false
);
$errors = array();
$events = (array) (isset($options['events']) ? $options['events'] : null);
@@ -460,6 +461,10 @@ public static function check(array $values, array $rules, array $options = array
}
if (!static::rule($name, $values[$field], $rule['format'], $rule + $options)) {
$errors[$field][] = $rule['message'] ?: $key;
+
+ if ($rule['last']) {
+ break;
+ }
}
}
}

0 comments on commit afe30c7

Please sign in to comment.