I think I ran over a solution that fits my needs.
http://bakery.cakephp.org/articles/view/multivalidatablebehavior-using-many-validation-rulesets-per-model
Instead of defining several rules for each field, this behavior implies defining several βgeneralβ rules, according to which you define all your rules associated with the field.
So, instead of doing:
var $validate=array( "username" => array( "usernameCheckForRegister" => array( "rule" => ..., "message" => ... ), "usernameCheckForLogin" => array( "rule" => ..., "message" => ... ) ),
:
var $validate = array( 'username' => , 'password' => , 'email' => ); var $validationSets = array( 'register' => array( 'username' => , 'password' => , 'email' => , ), 'login' => array( 'username' => , 'password' => ) );
And then in your controller, you switch between verification sets as follows: $this->User->setValidation('register');
Even if you need to write a little more code, I think this solution best suits my needs.
linkyndy
source share