有没有办法将验证条件设置为"严格大于"?

wce*_*ceo 3 hibernate hibernate-validator

我想知道Hibernate验证器@Min是否包含(等于或大于)有没有办法表达"严格大于"一个数字?

非常感谢 :)

Gun*_*nar 8

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.


Har*_*rdy 4

没有内置的约束。您需要自定义约束。但如果你处理的是整数,你总是可以使用 @Min 和你的限制 + 1。