Home > Net >  Bean-Validate minimum and maximum value for LocalDate
Bean-Validate minimum and maximum value for LocalDate

Time:05-18

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).

CodePudding user response:

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

CodePudding user response:

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.

  • Related