[bv-dev] Proposal for supporting new Java 8 date/time types

John Hendrikx hjohn at xs4all.nl
Fri Sep 23 03:04:40 EDT 2016


>     > Another thing: If @Future and @Past support types like LocalDate,
>     YearMonth and Year, should we perhaps enhance them to allow the user
>     to specify that the "current" year/month/date should also be valid?
>
>     That's a very good point, too! This one has been specifically
>     brought up with https://hibernate.atlassian.net/browse/BVAL-466
>     <https://hibernate.atlassian.net/browse/BVAL-466>. It seems sensible
>     to add an annotation parameter for this given the support for these
>     non-instant types. When looking at your example, I'd have a hard
>     time though to reason the exact semantics of inclusive(). I hope we
>     could find something more descriptive?
>
>
> I agree that "inclusive" isn't a good name. I'm open for any ideas. ;-)

Perhaps just provide annotations for their inverse.

NotFuture/NotInFuture = past + now (past inclusive)
NotPast/NotInPast = future + now (future inclusive)

Or perhaps a general modifying annotation, that can be applied to 
everything to invert the matching logic:

@Not

Inverts the matching logic on this element.

@Not @Past
@Not @Pattern("TRUE|FALSE")  // hard to write without the @Not

--John


More information about the beanvalidation-dev mailing list