Reputation: 2838
Am getting an error while trying to integrate validation in kohana. following are error details
Error message title
ErrorException [ Fatal Error ]: Class 'Validate' not found
APPPATH\classes\Controller\home.php [ 24 ]
19 {
20 $_model = Model::factory('home');
21
22 if ($this->request->method() == HTTP_Request::POST)
23 {
24 $post = Validate::factory($_POST)
25 ->filter(TRUE, 'trim')
26 ->filter('txt_name', 'strtolower')
27
28 ->rule('txt_name', 'not_empty')
29 ->rule('txt_name', 'regex', array('/^[a-z_.]++$/iD'))
Please help me to solve this.
Upvotes: 0
Views: 1286
Reputation: 1556
What version of Kohana are you using? For Kohana 3.3 it should be:
Validation::factory($_POST)
Also you can use $this->request->post()
instead of $_POST
Looks like the filter method was deprecated from Kohana 3.2 so you could do the following as suggested here: How do I call the trim function on a Kohana 3.2 validation object?
$post = array_map('trim', $this->request->post());
$post = Validation::factory($post)
->rule('txt_name', 'not_empty')
->rule('txt_name', 'regex', array('/^[a-z_.]++$/iD'));
Or alternatively, you could use http://kohanaframework.org/3.3/guide/orm/filters
Upvotes: 1