Validate form without model

Hello,

I need to validate fields of a form without the form is the representation of a model. The class performs the validation only on the validated model.

http://www.yiiframework.com/doc/api/1.1/CValidator#validate-detail

This page is indicated Cmodel as first parameters

Is there a way to do validation without creating the model?

Try use the function validateValue().

Ex:

If you want to validate the value is a valid email address.




$email=$_POST['email'];

$v=new CEmailValidator();

$v->validateValue($email); 



thanks,

but that method is only available for e-mails and urls, but not for all types of data. It also does not checks if the field is empty. Other tips?

You may extend the Validator for a custom.

EX:




class MyNumberValidator extends CNumberValidator {

     public function validateValue()

     {

          // your code here

     }

}



mmm. really looking for something ready. I guess I have to choose this path. if anyone has other solutions are well

thanks

Declare a class extending CFormModel. Those can have rules just like classes extending CActiveRecord.