Why not have several validation rules for one field?

var $validate = array(
        'val1' => array(
                'required' => array(
                        'rule' => VALID_NOT_EMPTY,
                        'required' => true,
                        'allowEmpty' => false,
                        'last' => true,
                        'message' => 'xxxxxxxx'
                ),
                'format' => array(
                        'rule' => array('val1'),
                        'last' => true,
                        'message' => 'yyyyyyy'
                ),
                'is_unique' => array(
                        'rule' => array('isUnique'),
                        'message' => 'zzzzzzzzz'
                ),
                .....
        ),
        .....
);

If this 'generic' and proposed approach is not good for you, you can
allways (from model) call $this->invalidate('field', 'Error message'),
but keep in mind that error messages are better to keep in views, then
in models ('M' layer doesn't need to know about messages for humans,
they are supposed to live in human interface - 'V' layer of MVC app).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to