From 035de87cf7ce01f04761ee10fc99bf626c93206c Mon Sep 17 00:00:00 2001 From: Joel Clermont Date: Tue, 5 Mar 2013 14:14:34 -0600 Subject: [PATCH] update rules method to be more consistent with rule method --- src/Valitron/Validator.php | 4 +++- tests/Valitron/Validate.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Valitron/Validator.php b/src/Valitron/Validator.php index 9bb36fc..9df216b 100644 --- a/src/Valitron/Validator.php +++ b/src/Valitron/Validator.php @@ -516,7 +516,9 @@ class Validator { foreach ($rules as $ruleType => $params) { if (is_array($params) && !empty($params)) { - if (is_array($params[0])) { + // differentiate between a single rule taking an array of params + // and an array of rules within a single type + if (count($params) > 1 && is_array($params[0]) && is_array($params[1])) { foreach ($params as $innerParams) { $this->callRuleWithParams($ruleType, $innerParams); } diff --git a/tests/Valitron/Validate.php b/tests/Valitron/Validate.php index d7f8fce..a07b800 100644 --- a/tests/Valitron/Validate.php +++ b/tests/Valitron/Validate.php @@ -421,7 +421,7 @@ class ValidateTest extends \PHPUnit_Framework_TestCase public function testAcceptBulkRulesWithMultipleParams() { $rules = array( - 'required' => array('nonexistent_field', 'other_missing_field'), + 'required' => array(array('nonexistent_field', 'other_missing_field')), 'equals' => array('foo', 'bar'), 'length' => array('foo', 5) );