From 3ee508987e69687ace968c967961b4f92894d8c1 Mon Sep 17 00:00:00 2001 From: Chris Van Patten Date: Tue, 5 Jan 2016 09:48:23 -0500 Subject: [PATCH 1/2] Pass $this->_fields to callbacks defined in addRule --- src/Valitron/Validator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Valitron/Validator.php b/src/Valitron/Validator.php index 7322357..6a48c56 100644 --- a/src/Valitron/Validator.php +++ b/src/Valitron/Validator.php @@ -885,7 +885,7 @@ class Validator $result = true; foreach ($values as $value) { - $result = $result && call_user_func($callback, $field, $value, $v['params']); + $result = $result && call_user_func($callback, $field, $value, $v['params'], $this->_fields); } if (!$result) { From 920fefc05a57bc4615cdf851238e6697cc00c3bc Mon Sep 17 00:00:00 2001 From: Chris Van Patten Date: Tue, 5 Jan 2016 09:57:16 -0500 Subject: [PATCH 2/2] update README to include $fields callback param in code example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4854fa1..9382df2 100644 --- a/README.md +++ b/README.md @@ -182,7 +182,7 @@ case of an error. The callback provided should return boolean true or false. ```php -Valitron\Validator::addRule('alwaysFail', function($field, $value, array $params) { +Valitron\Validator::addRule('alwaysFail', function($field, $value, array $params, array $fields) { return false; }, 'Everything you do is wrong. You fail.'); ```