mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-31 07:01:54 +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)
|
protected function validateSlug($field, $value)
|
||||||
{
|
{
|
||||||
|
if(is_array($value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return preg_match('/^([-a-z0-9_-])+$/i', $value);
|
return preg_match('/^([-a-z0-9_-])+$/i', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -617,6 +617,13 @@ class ValidateTest extends BaseTestCase
|
|||||||
$this->assertFalse($v->validate());
|
$this->assertFalse($v->validate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testNoErrorFailOnArray()
|
||||||
|
{
|
||||||
|
$v = new Validator(array('test' => array()));
|
||||||
|
$v->rule('slug', 'test');
|
||||||
|
$this->assertFalse($v->validate());
|
||||||
|
}
|
||||||
|
|
||||||
public function testRegexValid()
|
public function testRegexValid()
|
||||||
{
|
{
|
||||||
$v = new Validator(array('test' => '42'));
|
$v = new Validator(array('test' => '42'));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user