mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-31 07:01:54 +00:00
update rules method to be more consistent with rule method
This commit is contained in:
parent
ca553cf658
commit
035de87cf7
@ -516,7 +516,9 @@ class Validator
|
|||||||
{
|
{
|
||||||
foreach ($rules as $ruleType => $params) {
|
foreach ($rules as $ruleType => $params) {
|
||||||
if (is_array($params) && !empty($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) {
|
foreach ($params as $innerParams) {
|
||||||
$this->callRuleWithParams($ruleType, $innerParams);
|
$this->callRuleWithParams($ruleType, $innerParams);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -421,7 +421,7 @@ class ValidateTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testAcceptBulkRulesWithMultipleParams()
|
public function testAcceptBulkRulesWithMultipleParams()
|
||||||
{
|
{
|
||||||
$rules = array(
|
$rules = array(
|
||||||
'required' => array('nonexistent_field', 'other_missing_field'),
|
'required' => array(array('nonexistent_field', 'other_missing_field')),
|
||||||
'equals' => array('foo', 'bar'),
|
'equals' => array('foo', 'bar'),
|
||||||
'length' => array('foo', 5)
|
'length' => array('foo', 5)
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user