How to compare attributes in rules like n=+1 or something related.

I can’t find out how to solve my issue.

I have two attributes: sy1 and sy2. This attributes are used for school year duration e.g. 1991-1992, 1992-1993.

I need to put something in my model::rules() so that it will check whether sy1 is sy2-1 or sy2 is sy1+1.

my current rule is

array('sy1', 'compare','compareAttribute'=>'sy2', 'operator'=>'<')

I need to put further conditions like +1 or -1.

TIA :)

You should create a custom validator.