Chris Hayes
Chris Hayes

Reputation: 127

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?

Upvotes: 2

Views: 619

Answers (1)

Mr Sooul
Mr Sooul

Reputation: 699

$post = Validation::factory($_POST)
    ->rule('username', 'not_empty');

Just remove "Valid::". :)

Upvotes: 2

Related Questions