开发者

Kohana validation without message files

Is there a way to use Kohana's (3+) validation class without using message files?

[EDIT]

Here is an example:

$post = Validate::factory($_POST);
$post
    ->开发者_Go百科rule('username', 'not_empty')
    ->rule('username', 'regex', array('/^[a-z_.]++$/iD'))

    ->rule('password', 'not_empty')
    ->rule('password', 'min_length', array('6'))
    ->rule('confirm',  'matches', array('password'))

    ->rule('use_ssl', 'not_empty');

The error message will be readed from message files, but I want to hardcode the error messages in source code. For example:

$post->rules->('username', 'not_empty', 'Please give your username');


You'd have to extend the Validation public function errors($file = NULL, $translate = TRUE) public function rules($field, array $rules) and public function rule($field, $rule, array $params = NULL) methods and implement with your own code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜