mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-30 23:01:52 +00:00
Merge pull request #200 from auroraeosrose/patch-1
Fix issue where preg_match spews when passed an array
This commit is contained in:
commit
1d8abc73b6
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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()
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user