我有两个自定义验证规则(我已经测试过它们正常工作):
class PasswordResetKey extends AppModel {
public $validate = array(
'timestamp' => array(
'rule' => '_notExpired',
'message' => 'Your password reset link has expired. Please request another one.',
'last' => true
),
'key' => array(
'rule' => '_validFormat',
'message' => 'You do not appear to have used a valid password reset link. Please request another one.'
)
);
但无论我做什么,返回的错误始终是:
Array
(
[key] => You do not appear to have used a valid password reset link. Please request another one.
[timestamp] => Your password reset link has expired. Please request another one.
)
即使我检查时间戳规则失败,它仍会继续并检查另一个规则是否为“密钥”。我只想要时间戳错误。
答案 0 :(得分:2)
最后是每个字段的多规则。由于你每个领域只有一个规则,所以它总是持续的,因而毫无意义。
答案 1 :(得分:0)
我的直觉说如果重置链接错误,_notExpired
不应该触发。只有在链接正确但已过期的情况下,我才会提出该规则。