Optional Validation Of A Field


I have a question regarding setting the rules. I have an email textbox and I want to validate it only when the field is not empty. If the field is empty then the rule is skipped. How can I achieve this in Yii.

Thanks in advance.

Most built-in validator classes (including CEmailValidator) have an allowEmpty property. Just set it to true.