I have an entity object with some fields (first name, last name, city, etc.). In one case I need to apply to this object one set of restrictions(not null, length restriction, unique and so on), in other case other set. At the moment I am using my own validator, which has different validation methods for different use cases.
Can I perform validation in another different way (standard solution)?
I use Spring with Hibernate. JSR303 standard which is implemented in Hibernate can't resolve my problem, because annotations allow to define only one set of restrictions which is static. I can't redefine it at runtime.