[hibernate-dev] [Bean Validation] @Max / @Min as double instead of long
Elias Ross
genman at noderunner.net
Wed Mar 4 19:14:48 EST 2009
On Wed, Mar 4, 2009 at 3:49 PM, Emmanuel Bernard <emmanuel at hibernate.org> wrote:
> [Follow up with Sebastian]
>
> Well good point and frankly I do not know :)
> 1. do we support float and double for @Min / @Max?
> 2. if 1 is yes, I'd be inclined to say the value should be double but that's
> not fully automatic.
How would you go about supporting @Max / @Min for java.math.BigDecimal
? These would be more useful, since think a lot of this sort of
validation is intended to fulfill business rules and business math
requires exact (not floating point) math.
And even in situations you use floating point math, the input and
state should be probably a BigDecimal value but internally
calculations could be done (for sake of expedience) using a double
conversion.
I would probably create a separate @MaxDouble and @MinDouble
annotation, if at all, but I wouldn't feel easy suggesting users build
constraints using floating point comparisons.
More information about the hibernate-dev
mailing list