diff --git a/src/Valitron/Validator.php b/src/Valitron/Validator.php index 5fc5c84..f6bd446 100644 --- a/src/Valitron/Validator.php +++ b/src/Valitron/Validator.php @@ -565,6 +565,9 @@ class Validator */ protected function validateSlug($field, $value) { + if(is_array($value)) { + return false; + } return preg_match('/^([-a-z0-9_-])+$/i', $value); } diff --git a/tests/Valitron/ValidateTest.php b/tests/Valitron/ValidateTest.php index 490424e..0bd0754 100644 --- a/tests/Valitron/ValidateTest.php +++ b/tests/Valitron/ValidateTest.php @@ -616,6 +616,13 @@ class ValidateTest extends BaseTestCase $v->rule('slug', 'test'); $this->assertFalse($v->validate()); } + + public function testNoErrorFailOnArray() + { + $v = new Validator(array('test' => array())); + $v->rule('slug', 'test'); + $this->assertFalse($v->validate()); + } public function testRegexValid() {