Skip to content

Commit

Permalink
Allowing $options from Model::validates() to Validator::check().
Browse files Browse the repository at this point in the history
  • Loading branch information
nateabele authored and gwoo committed Mar 30, 2010
1 parent 39ade28 commit c0a3feb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libraries/lithium/util/Validator.php
Expand Up @@ -314,7 +314,7 @@ public static function __callStatic($method, $args = array()) {
* @param string $rules array of rules to check against object properties
* @return mixed When all validation rules pass
*/
public static function check($values, $rules) {
public static function check($values, $rules, array $options = array()) {
$defaults = array(
'notEmpty',
'message' => null,
Expand All @@ -331,7 +331,7 @@ public static function check($values, $rules) {
$errors[$field] = array();

foreach ($rules as $key => $rule) {
$rule += $defaults;
$rule += $defaults + compact('values');
list($name) = $rule;

if (!isset($values[$field])) {
Expand All @@ -343,7 +343,7 @@ public static function check($values, $rules) {
if (empty($values[$field]) && $rule['skipEmpty']) {
continue;
}
if (!static::rule($name, $values[$field], $rule['format'], $rule)) {
if (!static::rule($name, $values[$field], $rule['format'], $rule + $options)) {
$errors[$field][] = $rule['message'] ?: $key;
}
}
Expand Down

0 comments on commit c0a3feb

Please sign in to comment.