0

I want to create an annotation from several, such as @JsonUnwrapped and @Valid from javax.validation.

@JsonUnwrapped
@Valid
@JacksonAnnotationsInside
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ComplexUnwrapped {
}

Here's how I use:

@ComplexUnwrapped
TestParams testParams;

But validation doesn't work. Please tell me what else needs to be done, or poke into the documentation, I don't know how to Google and find (

Igor
  • 47
  • 5
  • 1
    You're trying to use a concept called _meta-annotation_, which isn't a feature that's supported by the core Java system. Certain libraries that inspect annotations support meta-annotations, but only if they've been written to do so specifically, and you need to check (1) whether Bean Validation does, generally, and (2) whether the specific place you're applying it will see it (e.g., if a container needs to know to invoke the validator). – chrylis -cautiouslyoptimistic- Nov 02 '21 at 20:07
  • as an implementation, I use hibernate validator. (1) In general, the component is validated, but only if I use the @Valid annotation directly above the validated field inside the class. (2) Unfortunately, I don't understand how I can interfere in the process and trigger validation when using a custom annotation – Igor Nov 02 '21 at 20:23

0 Answers0