【发布时间】:2011-09-28 10:20:27
【问题描述】:
有没有办法在不使用消息文件的情况下使用 Kohana 的 (3+) 验证类?
[编辑]
这是一个例子:
$post = Validate::factory($_POST);
$post
->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');
错误消息将从消息文件中读取,但我想在源代码中对错误消息进行硬编码。例如:
$post->rules->('username', 'not_empty', 'Please give your username');
【问题讨论】:
-
你能澄清一下“不使用消息文件”是什么意思吗?是否要设置来自其他来源的验证错误消息?
-
你会在你的代码中引起问题。
-
@ThePixelDeveloper 如果我在代码中对错误消息进行硬编码会导致问题,或者您是否引用了其他内容?
标签: php validation kohana