Maybe I'm just being blind, but I don't think the below use case is possible with the current codebase.
It would be a very useful addition though.
Use case
I have a field set in date format d M yyyy (day precision only, no time fields)
I wish to validate that the date is not in the past
must be either today OR in the future
Problem
When passing a date with no time, SimpleDateFormat.parse will produce a Date object with time as midnight (00:00:00).
@Future validates using new Date(), so it'll have today's date + the time. Thus the compared timestamp is greater than the one produced by format.parse, so the date will fail validation.
@Past uses similar comparison point, so would return true for parse(Today), but returns false for parse(Today+n)
Possible solutions
add a @Today validator, which checks if the date given is within the same day.
then I can check @Future @Or @Today
Add addition parameters to @Future and @Past to specify a day only precision
Maybe I'm just being blind, but I don't think the below use case is possible with the current codebase. It would be a very useful addition though.
Use case
d M yyyy
(day precision only, no time fields)Problem
SimpleDateFormat.parse
will produce a Date object with time as midnight (00:00:00).@Future
validates usingnew Date()
, so it'll have today's date + the time. Thus the compared timestamp is greater than the one produced by format.parse, so the date will fail validation.@Past
uses similar comparison point, so would return true forparse(Today)
, but returns false forparse(Today+n)
Possible solutions
@Today
validator, which checks if the date given is within the same day.@Future @Or @Today
@Future
and@Past
to specify a day only precision