I\'m creating a Spring-Boot microservice REST API that expects @RequestParam
of type List
. How can I validate that the list contains
You can use a Class and @RequestBody for parameter validation, which is successful like me.
public class Test {
@Size(min = 1 , max = 5)
private List programEndTime;
public List getProgramEndTime() {
return programEndTime;
}
public void setProgramEndTime(List programEndTime) {
this.programEndTime = programEndTime;
}
}
@PostMapping("test")
public void test( @Valid @RequestBody Test test,
BindingResult result){
if (result.hasErrors()) {
System.out.println("Error");
} else {
System.out.println("OK");
}
System.out.println(",.,.");
}