I have a scenario where json request is made of different custom objects like:
{
"person:":{
"name":"xyx",
"age":25
},
"movieList":[
{
"name":"yyy",
"duration":34,
"language":"english"
},
{
"name":"zzz",
"duration":37,
"language":"english"
}
]
}
and the java class looks like
public class Customer{
private Person person,
private List<MovieList> movieList;
}
Condition for validation:Fields cannot be null
Now coming to spring controller i want to validate each object coming from the request,and i am able to validate as whole Customer object since BindingResult is applied on the entire request Body.But my requirement is to validate Person Object and MovieList object separately.
public void createCustomer(@RequestBody Customer customer,BindingResult result){
}
and also my requirement is to throw an exception of specific object which is causing the exception to happen since my framework is designed that way.