In Yii how to apply the model validator field to an arbitrary variable?

Salute! actually interested in the subject. Have yii is the mechanism of model validation before saving data ka who wants to use it to make the code more slender and not to use bicycles. As you can variable which is "not the model" test? Let's say I have a variable email, which arrives with the form.

It is certainly possible to create an empty model in her field, set validation rules. And assign a value to my variable, but it is bulky it turns out. All the same, or in this case a better bike?

Upd: Found one version through the creation of a shape model dummy.
October 3rd 19 at 04:32
3 answers
October 3rd 19 at 04:34
Somehow so?
$validator=new CEmailValidator;
 throw new CHttpException(500,'Not an email');
 } else
 echo 'OK';
amiss, thank you! - nasir commented on October 3rd 19 at 04:37
October 3rd 19 at 04:36
In fact, nothing cumbersome, for forms there is a special CFormModel, look at the feedback form as a reference. Email today to check, tomorrow something else, better make it right.
Yes, I do not for forms actually. I have the data just stored in the table:
field name | field value
each line is a separate field with its own validators.
Trying to figure out how to do it competently. - nasir commented on October 3rd 19 at 04:39
October 3rd 19 at 04:38
There is Also, if of course we are talking about the model. But alternatively, you can use the factory in yii, create a CValidator and providerbut any value.

Find more questions by tags ValidationYii