@size(max = value)和@min(value)@max(value)之间的差异 [英] difference between @size(max = value ) and @min(value) @max(value)
问题描述
我希望其他人进行域验证
I want ot do some domain validation
在我的对象中,我有一个整数,
in my object i am having one integer ,
现在我的问题是我是否写
now my question is if i write
@Min(SEQ_MIN_VALUE)
@Max(SEQ_MAX_VALUE)
private Integer sequence;
和
@Size(min = 1, max = NAME_MAX_LENGTH)
private Integer sequence;
如果是整数,则该整数适合域验证.
If it's integer which one is proper for domain validation.
有人可以解释一下他们之间的区别吗?
can anybody explain me what is the difference between them ?
谢谢.
推荐答案
@Min
和@Max
用于验证可能为String
(代表数字),int
,short
,byte
等及其各自的原始包装器.
@Min
and @Max
are used for validating numeric fields which could be String
(representing number), int
, short
, byte
etc and their respective primitive wrappers.
@Size
用于检查字段的长度约束.
@Size
is used to check the length constraints on the fields.
根据文档,@Size
支持String
,Collection
,Map
和arrays
,而@Min
和@Max
支持基元及其包装.参见文档.
As per documentation @Size
supports String
, Collection
, Map
and arrays
while @Min
and @Max
supports primitives and their wrappers. See the documentation.
这篇关于@size(max = value)和@min(value)@max(value)之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!