且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

@size(max = value)和@min(value)@max(value)之间的差异

更新时间:2022-01-03 09:05:31

@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.