mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-30 23:01:52 +00:00
Validate an array of discrete values
This commit is contained in:
parent
d71a928c60
commit
eace42656a
@ -803,6 +803,11 @@ class Validator
|
||||
|
||||
protected function getPart($data, $identifiers)
|
||||
{
|
||||
// Catches the case where the field is an array of discrete values
|
||||
if (is_array($identifiers) && count($identifiers) === 0) {
|
||||
return array($data, false);
|
||||
}
|
||||
|
||||
$identifier = array_shift($identifiers);
|
||||
|
||||
// Glob match
|
||||
|
||||
@ -308,6 +308,13 @@ class ValidateTest extends BaseTestCase
|
||||
$this->assertFalse($v->validate());
|
||||
}
|
||||
|
||||
public function testForeachDiscreteValues()
|
||||
{
|
||||
$v = new Validator(array('values' => array(5, 10, 15, 20, 25)));
|
||||
$v->rule('integer', 'values.*');
|
||||
$this->assertTrue($v->validate());
|
||||
}
|
||||
|
||||
public function testForeachArrayAccess()
|
||||
{
|
||||
$v = new Validator(array('settings' => array(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user