Question about validation in model

2007-06-12 Thread Gonza

When using model-validates($data), the lines of code that execute the
validation are:

foreach($this-validate as $field_name = $validator) {
   if (isset($data[$field_name])  !preg_match($validator,
$data[$field_name])) {
$this-invalidate($field_name);
   }
}

the problem with this is that if the variables is not defined, is not
validated, something weird, because if i told that a variable has to
be NOT_EMPTY and is not defined no error is thrown.
This behaviour is normal and i have to defined the variable always or
as i think when the variables were not defined model has to mark them
as not valid?

Thanks!
Gonza


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP 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
-~--~~~~--~~--~--~---



Re: Question about validation in model

2007-06-12 Thread Ketan Patel

Validation is used for validating data that exists and not for
confirming whether the variable is there or not! So if you are
expecting something and its not there then controller should take be
taking care of this information.



On Jun 12, 11:33 am, Gonza [EMAIL PROTECTED] wrote:
 When using model-validates($data), the lines of code that execute the
 validation are:

 foreach($this-validate as $field_name = $validator) {
if (isset($data[$field_name])  !preg_match($validator,
 $data[$field_name])) {
 $this-invalidate($field_name);
}

 }

 the problem with this is that if the variables is not defined, is not
 validated, something weird, because if i told that a variable has to
 be NOT_EMPTY and is not defined no error is thrown.
 This behaviour is normal and i have to defined the variable always or
 as i think when the variables were not defined model has to mark them
 as not valid?

 Thanks!
 Gonza


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP 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
-~--~~~~--~~--~--~---