Revision #2 has been created by nickcv on Mar 31, 2011, 9:41:23 AM with the memo:
made correction to headers
« previous (#1) next (#3) »
Create your own Validation Rule
validator, validation rules, model validation, create validator
Some times the core validation rules provided by Yii won't satisfy all your needs, so you'll need to create your very own validation rule.
Easy approach: inside-model rule
The easiest way to create a new validation rule is inside the model that is going to use it.
[...]Add Error accepts two parameters: the first one is the name of the attribute that you want to display the error in your form, the second one is the actual error string you want to be displayed.
Complete approach: extending the CValidator class
If you need your custom validation rule in more then one model the best thing to do is extending the CValidator class.
Extending this class you also can take advantage of other features, like [CActiveForm::$enableClientValidation](http://www.yiiframework.com/doc/api/1.1/CActiveForm#enableClientValidation-detail), first implemented with Yii 1.1.7 release.
##Creating the class file