A year ago I have posted about how to create template dependent field validator with rules engine. But it requires too many modifications, so I have decided to write this post about how to do the similar functionality without rules engine.
So at first I have implemented a base class which should be used by all validators which want to be dependent on a template or a base template. This class does the following steps:
- Checks the template ID and base template ID of the current item
- If it is true then the main part is called, this is the following line:
This is the injected specific validation method which is passed as a parameter.