简体   繁体   中英

How to validate size of elements inside a list with javax?

How can I validate the length of the elements inside a list with javax.validation ?

@Size(min = 2, max = 3)
private String value;

private List<String> list;

hibernate-validator 5.2.x将支持以下语法,这很棒:

List<@Length(min = 2, max = 3) String> list;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM