For the current project we’re using JSR-303 annotations to validate our interface parameters.
I needed to create a custom annotation for dates, as the default @Past and @Before also take into account the time.
This is the definition of my annotation:
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = { NotInFutureValidator.class })
/**
* Annotated element must be a date before tomorrow, compared to the system's date
*/
public @interface NotInFuture {
String message() default "{be.credoc.contractRegistration.interface_v2.validation.pastignoretime}";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
The implementation of the validator is pretty straight forward.
Our webapplication is written in GWT and it makes use of gwt-validation. This allows us to validate our parameters on client side by means of the same annotations.
However, when I annotate my parameters with my custom annotation and I want to validate it by making use of the GwtValidatorFactory, it doesn’t give me an error when the input date is in the future.
Does anyone have experiencing defining and using their own annotations in a GWT application and can see what I’m missing?
Thanks in advance
Apparently we wrote our own JavaScript implementations for each custom annotation, so the solution in this case was to write such an implementation.