Hi
We place json content in string fields and would like to help the ui-users with asserting that their input is valid json.
Following the doc and blog, I was able to quickly create a custom “class-level” annotation that does the job.
@Target({ ElementType.TYPE })
@Retention(RUNTIME)
@Constraint(validatedBy = JsonFieldsValidator.class)
public @interface JsonFields {...}
However, when changing the annotation to ElementType.FIELD, I did not get the expected validation error messages when saving the changes. I did of course move the annotation from the entity to the corresponding String field in the entity.
@Target({ ElementType.FIELD })
@Retention(RUNTIME)
@Constraint(validatedBy = JsonFieldValidator.class)
public @interface JsonField {...}
Are custom annotations also supported for fields? If yes, what is wrong with my code?
Thanks
Oliver