[bv-dev] First Alpha release of Bean Validation 2.0 RI

Gunnar Morling gunnar at hibernate.org
Tue Feb 21 02:51:23 EST 2017


2017-02-20 20:13 GMT+01:00 Michael Nascimento <misterm at gmail.com>:
> On Fri, Feb 17, 2017 at 5:11 AM, Gunnar Morling <gunnar at hibernate.org>
> wrote:
>>
>> > You don't compare, because they are not the same. The idea is that the
>> > Period must be defined in terms of the units for which you defined its
>> > boundaries.
>>
>> I see. I'm wondering though how practical that will be. Will the
>> developer who puts the constraint always know the structure of the
>> Period set to the field (data set by the application user)?
>
>
> In the case you want it to be validated, you ought to :-)

But that's the problem, can you really?

The actual field values are set at application runtime, e.g. entered
by a user sitting in front of the application. So the application
developer would have to "lock down" whatever can be put in to match
the unit set in the constraint. It's doable but I'm having doubts that
this constraint pulls its eight eventually.

>
>>
>>
>> > You shouldn't support threeten-extra, but rather arbitrary
>> > TemporalAmounts.
>> > Then threeten-extra just happen to be one of those. There must be
>> > something
>> > like @ChronoUnitMax/@ChronoUnitMin such as:
>> >
>> > @ChronoUnitMax(unit=DAYS, value=1)
>>
>> How would that look like for a Period with several elements set, e.g.
>> "3 months, 2 days"? Would we need a dedicated member in @ChronoUnitMax
>> for each value of ChronoUnit (which are a lot)?
>
>
> What do you mean by a member in @ChronoUnitMax? In my example, I suggest
> using unit as a member, leading to unit and value being the only members.

By member I meant months(), days(), hours() etc. In the "one unit, one
value" model, how would you express "max 3 month and two weeks"? We
could exclude such case of course, it may sufficiently well be
expressed as "max 10 weeks".

>
>>
>> We had a discussion of Duration et al. a while ago, but it petered
>> out. So we thought we'd add something to the RI to spark a new
>> discussion. Seems it worked :)
>
>
> Can´t disagree :-)
>
> Regards,
> Michael
>
> _______________________________________________
> beanvalidation-dev mailing list
> beanvalidation-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/beanvalidation-dev



More information about the beanvalidation-dev mailing list