wceo
wceo

Reputation: 934

Is there a way to set the validation condition to "strictly greater than"?

I would like to know instead of the Hibernate validator @Min which is inclusive (equal or greater than) is there a way to express "strictly greater than" a number?

Thanks very much :)

Upvotes: 5

Views: 7739

Answers (2)

Gunnar
Gunnar

Reputation: 19010

If you work with Bean Validation 1.1 (part of Java EE 7) you may use @DecimalMin instead which has an additional attribute, inclusive, which controls whether "strictly greater than" or "greater than or equals to" semantics are used.

Upvotes: 10

Hardy
Hardy

Reputation: 19129

Not with the built-in constraints. You would need a custom constraints. But if you are dealing with integers you can always use @Min with your limit + 1.

Upvotes: 4

Related Questions