Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bean Validation for @Past or today?

Here's a simple source, stating that this date must be in the past using Bean Validation :

@Past
private Date transactionDate;

Is there any BV annotation for validating that the date must be today or previous day?

Or perhaps I need to extend the constraint and provide my own?

like image 359
Albert Gan Avatar asked Mar 19 '11 04:03

Albert Gan


2 Answers

To get past and today you can use

@PastOrPresent
like image 120
prakash joy Avatar answered Oct 19 '22 12:10

prakash joy


Just found out the answer for this, @Past means today or any day before today.

So, using @Past suits my need without having to provide my own constraint.

like image 24
Albert Gan Avatar answered Oct 19 '22 11:10

Albert Gan