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:

www.yiiframework.com/doc-2.0/guide-input-validation.html#creating-validators

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

http://www.yiiframework.com/wiki/782/how-to-validate-the-uniqueness-of-multiple-columns