Igor Belykh
Igor Belykh

Reputation: 101

Kohana validation. How to use a lambda function to set rule?

I have a problem with Kohana's validation object. For example, I want to check the user_id field. It has to be a number and greater then 0. I've tried following:

$validation->rule("user_id", function($str){
  return (is_numeric($str) && $str > 0);
}

Also I put into the field, just a string "sdfgwertxcvb". But the $validation->check() returns "TRUE". Why?

Please, explain to me what did I do wrong?

Upvotes: 1

Views: 239

Answers (1)

Related Questions