mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-30 23:01:52 +00:00
Merge pull request #201 from auroraeosrose/foreachbug
Check if the value in getParts is non-scalar to prevent "Invalid argument to foreach" error
This commit is contained in:
commit
a6cf3a8c86
@ -892,6 +892,11 @@ class Validator
|
|||||||
if (is_array($identifiers) && count($identifiers) === 0) {
|
if (is_array($identifiers) && count($identifiers) === 0) {
|
||||||
return array($data, false);
|
return array($data, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Catches the case where the data isn't an array or object
|
||||||
|
if (is_scalar($data)) {
|
||||||
|
return array(NULL, false);
|
||||||
|
}
|
||||||
|
|
||||||
$identifier = array_shift($identifiers);
|
$identifier = array_shift($identifiers);
|
||||||
|
|
||||||
|
|||||||
@ -34,6 +34,13 @@ class ValidateTest extends BaseTestCase
|
|||||||
$v->rule('required', array('name', 'email'));
|
$v->rule('required', array('name', 'email'));
|
||||||
$this->assertFalse($v->validate());
|
$this->assertFalse($v->validate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testRequiredSubfieldsArrayStringValue()
|
||||||
|
{
|
||||||
|
$v = new Validator(array('name' => 'bob'));
|
||||||
|
$v->rule('required', array('name.*.red'));
|
||||||
|
$this->assertFalse($v->validate());
|
||||||
|
}
|
||||||
|
|
||||||
public function testRequiredValid()
|
public function testRequiredValid()
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user