开发者

Valid::not_empty in Kohana 3.1 always passes validation check

开发者 https://www.devze.com 2023-03-08 18:13 出处:网络
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, mea

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::". :)

0

精彩评论

暂无评论...
验证码 换一张
取 消