I tried looking in the API and within the code, but was unable to find
the reference to isUnique except for with reference for find() in the
Model class.  Is there an internal validation rule of `isUnique`
within v1.2?  Also while looking I found `last`, does anyone know what
that does exactly?

On May 13, 12:45 am, David Christopher Zentgraf <[EMAIL PROTECTED]>
wrote:
> Actually, you may run into problems with this:
>
> var $validate = array(
>         array(
>                 'rule' => array('validateUnique', 'email')
>         ),
> );
>
> function validateUnique($fieldValue, $fieldName) {
>         if (!$this->isUnique($fieldName)) {
>                 return false;
>         } else {
>                 return true;
>         }
>
> }
>
> When you have multiple models linked that have the same field names  
> with validation rules (e.g. two models with 'name', both of which have  
> validation rules), using this method doesn't properly prefix the field  
> names and you may get an SQL error about ambiguous column names in  
> certain circumstances.
>
> Here's what I ended up using:
>
> var $validate = array(
>         'name'          => array(
>                 'minlength'     => array('rule' => array('minLength', 2)),
>                 'unique'                => array('rule' => array('isUnique')),
>                 'required'      => array('rule' => array('custom', '/.*/'), 
> 'required' =>  
> true, 'on' => 'create'),
>                 'nonEmpty'      => array('rule' => array('custom', '/.*/'), 
> 'allowEmpty'  
> => false)
>         )
> );
>
> Thanks to Grant Cox for that.
>
> Chrs,
> Dav
>
> On 12 May 2008, at 20:49, gmwebs wrote:
>
>
>
>
>
> > I have posted what I have in my User model (running 1.2.x.x) at
> >http://bin.cakephp.org/view/646962640- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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