dongsu2807 2013-09-19 11:24
浏览 29
已采纳

ErrorException [致命错误]:未找到类“验证”

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.

  • 写回答

1条回答 默认 最新

  • doubo82706 2013-09-19 13:17
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 统计大规模图中的完全子图问题
  • ¥15 使用LM2596制作降压电路,一个能运行,一个不能
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 经gamit解算的cors站数据再经globk网平差得到的坐标做形变分析
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题
  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式