I have a Spring webapplication that uses hibernate validator for validation. I have constraint annotations that are located in a different project. I need to have validators for these constraints in my spring project because I need some services to perform validation. So the situation is: I cannot place my constraint validators in @Constraint(validatedBy = MyConstraintValidator.class) because the validator is in a different project, I cannot add a dependency because that would create a cyclic dependency and it is just not the way we want it. I noticed that javax.constraints don't have validators specified, it's just @Constraint(validatedBy= {}). But hibernate validator still knows how to validate them. Is there a way to tell my hibernate validator how to validate my constraints without specifying constaint-validators in my constraints?
I hope be able to validate this constraint:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Constraint(validatedBy = {})
public @interface OneOf {
String message() default "{OneOf}";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
Thanks!