mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-30 23:01:52 +00:00
Merge pull request #2 from willemwollebrants/master
Add tests for 'optional' rule
This commit is contained in:
commit
30b2ce8bc9
@ -1085,6 +1085,27 @@ class ValidateTest extends BaseTestCase
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function testOptionalProvidedValid()
|
||||
{
|
||||
$v = new Validator(array('address' => 'user@example.com'));
|
||||
$v->rule('optional', 'address')->rule('email', 'address');
|
||||
$this->assertTrue($v->validate());
|
||||
}
|
||||
|
||||
public function testOptionalProvidedInvalid()
|
||||
{
|
||||
$v = new Validator(array('address' => 'userexample.com'));
|
||||
$v->rule('optional', 'address')->rule('email', 'address');
|
||||
$this->assertFalse($v->validate());
|
||||
}
|
||||
|
||||
public function testOptionalNotProvided()
|
||||
{
|
||||
$v = new Validator(array());
|
||||
$v->rule('optional', 'address')->rule('email', 'address');
|
||||
$this->assertTrue($v->validate());
|
||||
}
|
||||
}
|
||||
|
||||
function sampleFunctionCallback($field, $value, array $params) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user