Код: Выделить всё
@NotBlank(message = "Field X can't be Blank.", errorCode = 23442)
Код: Выделить всё
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({FIELD, PARAMETER})
@Constraint(validatedBy = {NotBlankAnnotationProcessor.class})
public @interface NotBlank {
String message() default "{commons.validation.constraints.NotBlank.message}";
@SuppressWarnings("unused")
Class[] groups() default {};
@SuppressWarnings("unused")
Class
Подробнее здесь: [url]https://stackoverflow.com/questions/75854099/how-to-throw-a-custom-exception-on-validation-failure-using-a-custom-annotation[/url]