mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-30 23:01:52 +00:00
Always run 'accepted' validation (#101)
This commit is contained in:
parent
ec77d601ad
commit
86cdecf193
@ -945,7 +945,11 @@ class Validator
|
||||
// Don't validate if the field is not required and the value is empty
|
||||
if ($this->hasRule('optional', $field) && isset($values)) {
|
||||
//Continue with execution below if statement
|
||||
} elseif ($v['rule'] !== 'required' && !$this->hasRule('required', $field) && (! isset($values) || $values === '' || ($multiple && count($values) == 0))) {
|
||||
} elseif (
|
||||
$v['rule'] !== 'required' && !$this->hasRule('required', $field) &&
|
||||
$v['rule'] !== 'accepted' &&
|
||||
(! isset($values) || $values === '' || ($multiple && count($values) == 0))
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@ -98,6 +98,12 @@ class ValidateTest extends BaseTestCase
|
||||
$this->assertFalse($v->validate());
|
||||
}
|
||||
|
||||
public function testAcceptedNotSet(){
|
||||
$v = new Validator();
|
||||
$v->rule('accepted', 'agree');
|
||||
$this->assertFalse($v->validate());
|
||||
}
|
||||
|
||||
public function testNumericValid()
|
||||
{
|
||||
$v = new Validator(array('num' => '42.341569'));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user