Merge pull request #200 from auroraeosrose/patch-1

Fix issue where preg_match spews when passed an array
This commit is contained in:
Willem Wollebrants 2017-06-23 23:34:07 +02:00 committed by GitHub
commit 1d8abc73b6
2 changed files with 10 additions and 0 deletions

View File

@ -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);
}

View File

@ -617,6 +617,13 @@ class ValidateTest extends BaseTestCase
$this->assertFalse($v->validate());
}
public function testNoErrorFailOnArray()
{
$v = new Validator(array('test' => array()));
$v->rule('slug', 'test');
$this->assertFalse($v->validate());
}
public function testRegexValid()
{
$v = new Validator(array('test' => '42'));