diff --git a/src/Valitron/Validator.php b/src/Valitron/Validator.php index d68007a..098a2f0 100644 --- a/src/Valitron/Validator.php +++ b/src/Valitron/Validator.php @@ -350,13 +350,18 @@ class Validator * @internal param array $fields * @return bool */ - protected function validateIn($field, $value, $params, $strict = false) + protected function validateIn($field, $value, $params) { $isAssoc = array_values($params[0]) !== $params[0]; if ($isAssoc) { $params[0] = array_keys($params[0]); } + $strict = false; + if (isset($params[1])) { + $strict = $params[1]; + } + return in_array($value, $params[0], $strict); } diff --git a/tests/Valitron/ValidateTest.php b/tests/Valitron/ValidateTest.php index 385190c..f8d3c06 100644 --- a/tests/Valitron/ValidateTest.php +++ b/tests/Valitron/ValidateTest.php @@ -273,6 +273,13 @@ class ValidateTest extends BaseTestCase $this->assertTrue($v->validate()); } + public function testInStrictInvalid() + { + $v = new Validator(array('color' => '1')); + $v->rule('in', 'color', array(1, 2, 3), true); + $this->assertFalse($v->validate()); + } + public function testArrayValid() { $v = new Validator(array('colors' => array('yellow')));