@size(max = value)和@min(value)@max(value)之间的差异 [英] difference between @size(max = value ) and @min(value) @max(value)

查看:1403
本文介绍了@size(max = value)和@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(代表数字),intshortbyte等及其各自的原始包装器.

@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支持StringCollectionMaparrays,而@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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆