Permalink
Browse files

Change regexp validator for possible use modificators

  • Loading branch information...
unknown
unknown committed May 4, 2011
1 parent 8a0d34c commit 2fbdf149923c0786ed9e7900a41c24727161620c
@@ -14,7 +14,7 @@ public function __construct($regex)
public function validate($input)
{
return preg_match("/{$this->regex}/", $input);
return (bool) preg_match($this->regex, $input);
}
}
@@ -184,7 +184,7 @@ public function testObject()
public function testRegex()
{
$this->doTestValidator(v::regex('^[a-f]+$'), 'abcdxxxef');
$this->doTestValidator(v::regex('/^[a-f]+$/'), 'abcdxxxef');
}
public function testString()
@@ -7,16 +7,20 @@ class RegexTest extends \PHPUnit_Framework_TestCase
public function testRegexOk()
{
$v = new Regex('w+');
$this->assertTrue($v->assert('wpoiur'));
$v = new Regex('/^[a-z]+$/');
$this->assertTrue($v->validate('wpoiur'));
$this->assertFalse($v->validate('wPoiUur'));
$v = new Regex('/^[a-z]+$/i');
$this->assertTrue($v->validate('wPoiur'));
}
/**
* @expectedException Respect\Validation\Exceptions\RegexException
*/
public function testRegexNot()
{
$v = new Regex('^w+$');
$v = new Regex('/^w+$/');
$this->assertTrue($v->assert('w poiur'));
}
@@ -154,7 +154,7 @@ public function testObject()
public function testRegex()
{
v::regex('^[a-f]+$')->assert('abcdef');
v::regex('/^[a-f]+$/')->assert('abcdef');
}
public function testString()

0 comments on commit 2fbdf14

Please sign in to comment.