Pass variable into Rules

I am just learning YII2 and am studying the Rules and validation procedures.

How do you go about passing in a variable to a validation rule.

For example:

On a compareValue, how would i change the value to compare to dynamically.


['age'], 'compare', 'compareValue' => 30, 'operator' => '>='],

Where could I set the ‘30’ to a different value pragmatically?

Thanks

Well, one way is this :




['age'], 'compare', 'compareValue' => $this->someFunction(), 'operator' => '>=']

It’s what you expect? :unsure:

Sorry for late reply, but yes that is what I was looking for and now that it is in front of me, makes sense.

Thank you.

Scotty