CakePHP - Validation rule 'last' not working
I have two custom validation rules (I have tested they 开发者_StackOverflow社区work correctly):
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.'
)
);
But no matter what I do, the errors returned are always:
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.
)
Even when I check that the timestamp rule fails, it still goes on and checks the other rule for 'key' as well. I only want the timestamp error if it is there.
last is for multi rules per field. due to the fact that you only have one rule per field its always last and thus pointless.
My intuition says _notExpired
should not fire if the reset link is wrong. I would have that rule raise a flag only if the link is correct but expired.
精彩评论