'Bean-Validate minimum and maximum value for LocalDate

I would like to provide bean-validation for variable which is of the LocalDate type. The minimum acceptable value should be LocalDate.of(2020,1,1). The maximum acceptable value should be LocalDate.of(5874897,1,1).



Solution 1:[1]

You can use isBefore and isAfter method as shown here https://docs.oracle.com/javase/8/docs/api/java/time/LocalDate.html

Solution 2:[2]

Jakarta Bean Validation 2.0 added support for the java.time classes defined in JSR 310.

Search for articles and videos showing the new features. Read JSR 380.

I expect you can use @Min, and @Max with LocalDate but I’ve not yet verified.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sj221
Solution 2 Basil Bourque