|
I mean I now use a method like this:
@Field("end_date")
@ErrorDescription("The end date must be today, or in the future, but can't be in the past")
public static final class EndDateMustBeTodayOrFuturePayload implements ApiResponseOverridePayload { }
@AssertTrue(payload = EndDateMustBeTodayOrFuturePayload.class)
public boolean isEndDateIsTodayOrFutureValidation() {
if ( endDate == null ) {
return true;
}
return !endDate.isBefore(LocalDate.now());
}
The payload is just a way to customize an API error JSON response.
Gunnar Morling yes I could probably do that but it seems like a hack. Today must be saved in DB, and today must answered, so I don't think adding 1 day, validating and removing that day is very elegant Btw we have a generic way to validate the input of JAXRS methods and it will be hard to know on which case we have to use today and on which case we have to use today+1
|