JSR 303: How to Validate a Collection of annotated objects?

后端 未结 5 1409
悲&欢浪女
悲&欢浪女 2020-12-14 14:17

Is it possible to validate a collection of objects in JSR 303 - Jave Bean Validation where the collection itself does not have any annotations but the elements contained wit

5条回答
  •  一整个雨季
    2020-12-14 14:59

    As of Bean Validator 2.0, both of these approaches work:

    class MyDto {
    
        private List<@Valid MyBean> beans;
    }
    

    and

    class MyDto {
    
        @Valid
        private List beans;
    }
    

提交回复
热议问题