Loading tutorials
spring-boot-starter-validation is on the classpath. It also assumes your request DTO already carries constraint annotations such as @NotBlank and @Min. Here you will learn what turns those annotations into 5 min read@Valid to a @RequestBody parameter. It follows a failed validation from the moment the constraint is violated to the HTTP response, and it names the exception types you will5 min read@Valid on a @RequestBody parameter. You also need the validation starter on the classpath. Here you will turn validation failures into consistent JSON error bodies that clients ca6 min readspring-boot-starter-validation is on your classpath. Request bodies are validated with @Valid on a DTO. Path variables and query parameters are single values w6 min read@Valid @RequestBody, and handle MethodArgumentNotValidException in a @RestControllerAdvice, as covered earlier in this tutorial. It also assumes you know Java records and generics. Here you will learn why nest5 min read@Valid, and a @RestControllerAdvice that returns 400 responses. It covers the annotation, the validator class, parameters, custom messages, Spring integration, and the mistakes that most often make a cu4 min readCreateUserRequest DTO, the @Valid contro5 min read@Valid. It also assumes you know how MethodArgumentNotValidException is handled in a @RestControllerAdvice. If any of that is unfamiliar, review the earlier chapters first.5 min read@Valid on a @RequestBody. It also assumes you have a @RestControllerAdvice that handles MethodArgumentNotValidException, and that you have seen the basic custom constraint (annotation plus 5 min read@Valid, handle MethodArgumentNotValidException in a @RestControllerAdvice, and use @Validated on a controller. You should also know basic Spring dependency injection and how Spring proxies work at a high level.6 min read@Valid can be dropped from a controller parameter. An exception handler can start returning 500 instead of 400. This chapter shows how to test each layer with the cheapest test that catches the problem.4 min read