Spring boot, how to use @Valid with List<T>
My immediate suggestion is to wrap the List in another POJO bean. And use that as the request body parameter.
In your example.
@RequestMapping(value="/bulk", method = RequestMethod.POST)
public List<DataResponse> bulkAdd(@RequestBody @Valid StatusList statusList, BindingResult bindingResult) {
// some code here
}
and StatusList.java will be
@Valid
private List<Status> statuses;
//Getter //Setter //Constructors
I did not try it though.
Update: The accepted answer in this SO link gives a good explanation why bean validation are not supported on Lists.