I have create a validation annotation to validate the content of a string. The definition of my annotation looks like this:
@NotNull
@Size(min = 2, max = 128, groups = First.class)
@Pattern(regexp = "^(?!WP_([0-9])+$)[A-Z_][A-Z0-9_-]+", groups = Second.class)
@Target({FIELD, ANNOTATION_TYPE})
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = {})
@GroupSequence(value={First.class, Second.class})
public @interface ValidIntentName {
String message() default "";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
My problem is that i cannot order the @Size and @Pattern execution. I've tried a couple of things but no luck so far.
Basically I need @Size to be executed before @Pattern
First and Second interfaces are defined. There are no errors during compilation is just that during run-time @Patter is executed before @Size.
Any idea what I'm doing wrong?
I'm running Java 8.
Thanks