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) );