mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-30 23:01:52 +00:00
Handle malformed bulk rules (#204)
This commit is contained in:
parent
107d1eebc1
commit
ec77d601ad
@ -1199,6 +1199,9 @@ class Validator
|
||||
foreach ($rules as $ruleType => $params) {
|
||||
if (is_array($params)) {
|
||||
foreach ($params as $innerParams) {
|
||||
if (! is_array($innerParams)){
|
||||
$innerParams = (array) $innerParams;
|
||||
}
|
||||
array_unshift($innerParams, $ruleType);
|
||||
call_user_func_array(array($this, 'rule'), $innerParams);
|
||||
}
|
||||
|
||||
@ -892,6 +892,17 @@ class ValidateTest extends BaseTestCase
|
||||
$this->assertEquals($v1->errors(), $v2->errors());
|
||||
}
|
||||
|
||||
public function testMalformedBulkRules(){
|
||||
$v = new Validator();
|
||||
$v->rules(
|
||||
array(
|
||||
'required'=>array('foo', 'bar')
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertFalse($v->validate());
|
||||
}
|
||||
|
||||
public function testCustomLabelInMessage()
|
||||
{
|
||||
$v = new Valitron\Validator(array());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user