score:1

Check that you have included this dependency in pom.xml

<dependency> 
  <groupId>org.springframework.boot</groupId> 
  <artifactId>spring-boot-starter-validation</artifactId> 
</dependency>

score:3

You are using the annotations in the wrong way and your controller is also missing an annotation.

You should annotate your controller with @Validated:

@Validated
@RestController
@RequestMapping("/mycontroller")
public class MyController { ... }

And in your model class you need to place the annotations like this:

@NotEmpty
private List<@Valid Foo> foo;

The @Valid annotation will check if the items inside the list are also valid.


Related Query

More Query from same tag