update rules method to be more consistent with rule method

This commit is contained in:
Joel Clermont 2013-03-05 14:14:34 -06:00
parent ca553cf658
commit 035de87cf7
2 changed files with 4 additions and 2 deletions

View File

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

View File

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