0

I have a group of annotations that are always together like so:

@Valid
@ValidPropertyA(kind = "Standard")
@ValidPropertyB(kind = "Standard")
@ValidPropertyC(kind = "Standard")
private SomeReusableType type;

@Valid
@ValidPropertyA(kind = "large")
@ValidPropertyB(kind = "large")
@ValidPropertyC(kind = "large")
private SomeReusableType type;

I would like to compose these annotations into a single annotation @ValidReusableType, but the problem that I have is is how would I push the kind into each of the @ValidProperty's that are on the @ValidResuableType type?

@Valid
@ValidReusableType(kind = "standard")
private SomeReusableType type;

@Valid
@ValidReusableType(kind = "large")
private SomeReusableType type;

Is there any way to setup the composed annotation to have it so my ConstraintValidator still have access to the kind they are validating?

Rcunn87
  • 134
  • 2
  • 10

1 Answers1

0

No, it's not possible: each constraint is totally independent.

We don't inject any context from the composed annotation into the composing annotations validators.

Guillaume Smet
  • 9,921
  • 22
  • 29