Saturday, September 25, 2010

Re: how to use required => true in multiple validation

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

jeremyburns@classoutfit.com
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 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 cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: