Conditional rules in Yii?

I would like to increase the length of name when there is a numerical string attached at the end of the campaign name like ‘_232231’. Is there an elegant way to do this in Yii?

    $rules = array(

        array('name', 'length', 'min'=>5,'max'=>36),


This might be the most elegant way:

You can create a validator easily. In the following link there is a clear example, in which the validator "checkUniqueness" is created.