public class MyFutureValidator implements ConstraintValidator<Future, Date> {
public void initialize(Future constraintAnnotation) {}
public boolean isValid(Date value, ConstraintValidatorContext context) {
Date now = ...;
if( value.after( now ) ) {
context.disableDefaultConstraintViolation();
context
.buildConstraintViolationWithTemplate("Must be after {now}")
.setValue( "now", now )
.addConstraintViolation();
return false;
}
return true;
}
}