Valid::not_empty in Kohana 3.1 always passes validation check
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?
$post = Validation::factory($_POST)
->rule('username', 'not_empty');
Just remove "Valid::". :)
精彩评论