Yes of course, i did test it in if-block ... ;-)

Code looks like this:

if ($this->User->validates($this->data))
{
  // This block will be always executed
}

Anyway, i found how to work around it. Before if-block, i put set().
Code:

$this->User->set($this->data);
if ($this->User->validates())     // Really like this, without $this-
>data as input params.
{

}

At least it works now as it should be.
Next question, why is it now working? What did $this->Model->set() do?
Can you gimme short explanation?

Thanks ...

On Apr 8, 5:41 pm, brian <[email protected]> wrote:
> > $this->User->validates($this->data); // always return true
> > $this->User->save($this->data); // always return true, and try to save
>
> You say it always returns true, but are you testing that in an if block?
>
> On Wed, Apr 8, 2009 at 9:59 AM, Rhee <[email protected]> wrote:
>
> > Hi,
>
> > the data validation in my User Model always return true. Can anybody
> > tell me why?
>
> > In Model:
>
> >        var $validate = array (
> >                'login' => array (
> >                        'notempty' => array (
> >                                'rule'          => array('custom', 
> > VALID_NOT_EMPTY),
> >                                'message'       => 'Error'
> >                        ),
> >                        'unique' => array (
> >                                'rule'          => 'isUnique',
> >                                'message'       => 'Error'
> >                        ),
> >                        'minlength' => array (
> >                                'rule'          => array ('minLength', '5'),
> >                                'message'       => 'Error'
> >                        ),
> >                        'alphanumeric' => array (
> >                                'rule'          => 'alphaNumeric',
> >                                'message'       => 'Error
> >                        )
> >                ),
> >                'passwd' => array (
> >                        'minlength' => array (
> >                                'rule'          => array ('minLength', '8'),
> >                                'message'       => 'Error'
> >                        )
> >                ),
> >                'title' => array (
> >                        'rule'          => array ('inList', array ('Mr.', 
> > 'Mrs.')),
> >                        'message'       => 'Error'
> >                ),
> >                'forename' => array (
> >                        'rule'          => array('custom', VALID_NOT_EMPTY),
> >                        'message'       => 'Error'
> >                ),
> >                'name' => array (
> >                        'rule'          => array('custom', VALID_NOT_EMPTY),
> >                        'message'       => 'Error'
> >                ),
> >                'email' => array (
> >                        'rule'          => array ('email', true),
> >                        'message'       => 'Error'
> >                )
> >        );
>
> > In Controller:
>
> > $this->User->validates($this->data); // always return true
> > $this->User->save($this->data); // always return true, and try to save
> > the data, which is of course error, due to NOT NULL constrains in
> > database.
>
> > Thanks for the help.
--~--~---------~--~----~------------~-------~--~----~
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