Kohana 3:ORM验证消息

0 php validation message kohana-3 kohana-orm

我正在尝试在Kohana 3(Orm Model)中添加验证消息.

类/模型/ cliente.php

<?php defined('SYSPATH') or die('No direct script access.');

class Model_Cliente extends ORM {
 protected $_table_name = 'clientes';
 protected $_primary_key = 'id';
 protected $_has_one = array('loja' => array());
 protected $_rules = array(
  'responsavel' => array('not_empty' => array(), 'min_length' => array(3)),
  'email' => array('not_empty' => array(), 'email' => array()),
  'telefone' => array('regex' => array('/^(\(\d{2}\)|\d{2})[ -]?\d{4}[ -]?\d{4}$/'))
 );
}
?>
Run Code Online (Sandbox Code Playgroud)

消息/ cliente.php

<?php defined('SYSPATH') or die('No direct script access.');

return array(
    'responsavel' => array(
        'not_empty' => 'O nome do responsável não pode ficar em branco.',
        'min_length' => 'O nome do responsável deve conter 3 caracteres ou mais.'
    )
);

?>
Run Code Online (Sandbox Code Playgroud)

输出:

Array ( [responsavel] => Array ( [0] => not_empty [1] => Array ( ) ) [email] => Array ( [0] => not_empty [1] => Array ( ) ) ) 
Run Code Online (Sandbox Code Playgroud)

我没有得到任何验证消息,只是这个输出上面...任何ideia?谢谢.

Joh*_*han 6

今天有同样的问题.

解决方案:validate() - > errors('')而不是validate() - > errors().

这是来自https://github.com/samsoir/core/tree/master/classes/kohana的beta核心,但也许它在3.08中是相同的.