This question already has an answer here:
- JSR-303 @Valid annotation not working for list of child objects 4 answers
I have a request object
public class OrderRequest {
private List<Details> detailsList;
}
public class Details{
Private String id;
private List<Detail> detailList;
}
public class Detail{
@NotNull(message = "Please provide the inventory name")
Private String inventoryName;
Private String inventoryId;
Private String inventoryLoc;
}
and i want to validate each request object Detail for not null or not empty.
javax.validation.constraints.NotNull
@valid annotation is added for the controller class
@Valid @RequestBody final OrderRequest orderRequest
but it doesn't seem to work. what am i missing here?