Reputation: 127
I have a rule in Kohana 3.1 checking for a non-empty field that always passes the validation check even if empty. Valid::empty
will not return an error even when the field it's checking is empty, meaning a user could submit an empty form and $post->check
would return true.
$post = Validation::factory($_POST)
->rule('username', 'Valid::not_empty');
In this example $post->check()
will pass even when username
is empty. I do not understand the reason for this. If I am trying to validate a form and fields cannot be left empty a user can submit an empty form and it will pass the validation check.
What is the reason for this behaviour, and what is the best way to achieve the expected result?
Upvotes: 2
Views: 619
Reputation: 699
$post = Validation::factory($_POST)
->rule('username', 'not_empty');
Just remove "Valid::". :)
Upvotes: 2