Springboot – validate @RequestBody

Add @NotNull annotation on a field (you may need to change type to Integer), and add @Valid annotation on the method parameter of the controller.

Mono<String> question(@Valid @RequestBody Foo foo) {
public class Foo {

    private Integer important;
    private String something;

//constructors, getter, seters, toString

You can find more information here: https://lmonkiewicz.medium.com/the-power-of-spring-rest-api-validation-77be83edef

Leave a Comment