var $validate = array(
        'status' => array(
                'maxLength' => array( # this can be any label you want
                        'required' => true, # careful!
                        'allowEmpty' => false,
                        'rule' => array('maxLength', 5),
                        'message' => array('valErrMaxCharacters %s', 5), # a 
modification
of mine to allow better i18n support
                        'last' => true
                ),
                ... # other rules
        ),
        ... # other fields
);


On 25 Sep., 15:30, "Mariano C." <[email protected]> wrote:
> thanks. but what I doesn't understand in my case is where I should put
> required => true?
> I need to put it once inside id, or twice inside idRole-1 and
> idRole-2?
>
> On 25 Set, 14:49, Jeremy Burns | Class Outfit
>
>
>
> <[email protected]> wrote:
> > Yup - agreed. I always use 'last' => true for each rule in a multi-part 
> > rule array (except for the last part of course) and put them in the most 
> > sensible processing order from a user perspective - which probably means 
> > the most likely one to fail first or perhaps the most important rule.
>
> > Jeremy Burns
> > Class Outfit
>
> > [email protected]http://www.classoutfit.com
>
> > On 25 Sep 2010, at 13:47, euromark wrote:
>
> > > jeremy is right
> > > @seehttp://www.dereuromark.de/2010/09/21/saving-model-data-and-security/
> > > (The myth about “required” and “allowEmpty”) further down
>
> > > i would - in your case - suggest to use "last"=>true as well!
>
> > > On 25 Sep., 14:25, Jeremy Burns | Class Outfit
> > > <[email protected]> wrote:
> > >> I'm prepared to be corrected, but my understanding is that 'required => 
> > >> true' just means that the field must be present in the data array, and 
> > >> doesn't really test its value. So in your case, required => true might 
> > >> be enough.
>
> > >> Jeremy Burns
> > >> Class Outfit
>
> > >> [email protected]http://www.classoutfit.com
>
> > >> On 25 Sep 2010, at 12:20, Mariano C. wrote:
>
> > >>> Reading the doc there's explained that require isn't a "pure" rule, so
> > >>> I'm asking how can I use it in multiple validation per field case:
>
> > >>> example:
> > >>> var $validate = array
> > >>>    (
> > >>>            'id' => array(
> > >>>                    'idRule-1' => array(
> > >>>                       'rule' => 'isUnique',
> > >>>                       'message' => 'id is already registered.'
> > >>>                    ),
> > >>>                    'idRule-1' => array(
> > >>>                       'rule' => 
> > >>> '/^[a-z0-9]{3}-([a-z0-9]{5}-){3}[a-z0-9]{4}$/',
> > >>>                       'message' => 'Id field is not valid.'
> > >>>                    ),
>
> > >>>            )
> > >>> )
>
> > >>> How can I explain that ID field is required? where I can write this?
>
> > >>> Second question: "allowEmpty => false" is stricter than "required =>
> > >>> true"? My interpretation about allowEmpty => false is: field will be
> > >>> required and empty is not allowed. Am I right? If this, I could use
> > >>> allowEmpty in place of required.
>
> > >>> Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers 
> > >>> with their CakePHP related questions.
>
> > >>> You received this message because you are subscribed to the Google 
> > >>> Groups "CakePHP" group.
> > >>> To post to this group, send email to [email protected]
> > >>> To unsubscribe from this group, send email to
> > >>> [email protected] For more options, visit this 
> > >>> group athttp://groups.google.com/group/cake-php?hl=en
>
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others 
> > > with their CakePHP related questions.
>
> > > You received this message because you are subscribed to the Google Groups 
> > > "CakePHP" group.
> > > To post to this group, send email to [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected] For more options, visit this group 
> > > athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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