diff --git a/src/Valitron/Validator.php b/src/Valitron/Validator.php index 57ba39e..e6b7e16 100644 --- a/src/Valitron/Validator.php +++ b/src/Valitron/Validator.php @@ -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 diff --git a/tests/Valitron/ValidateTest.php b/tests/Valitron/ValidateTest.php index d9c006d..b954a88 100644 --- a/tests/Valitron/ValidateTest.php +++ b/tests/Valitron/ValidateTest.php @@ -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(