BTW is there any reason you say not to use afterValidate() function? I think it makes it a lot easier as I can set the attribute as 'required' in the rules and then do a simple check for the condition for when it needs to be required. And then use clearErrors() where needed.

With your solution above, theer is more code/processing and then I also have to manually define the attribute as 'required'.

Also I found that if I want to validate multiple attributes on a custom function, each attribute will get validated multiple times! I.e 3 attributes = 3 x validation for each attribute.

My suggestion was just because I consider more polite use the 'standard instrument' like rules instead of override the framework function, but is a pure question of style, no difference at all.

If you get validate many time is because you set the rule for more 3 attributes, so the rule will be applied to all attributes, 3 times. You have 2 options: create an attribute depending validate function or create a single function for all field to validate (function to be called once, so only one attribute should figure in rules).