mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-30 23:01:52 +00:00
Add tests for 'optional' rule
This commit is contained in:
parent
708235e0e4
commit
9afa605dc3
@ -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) {
|
function sampleFunctionCallback($field, $value, array $params) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user