Jakarta Validation
The Jakarta standard for declaring input rules as annotations on fields, such as @NotBlank and @Positive, and checking them automatically.
In more detail
Spring binds a request body, then validates it when the parameter is marked @Valid, reporting each violation before the service runs. Annotations suit simple field rules; rules that need context, such as whether a product exists, belong in the service. Hibernate Validator is the implementation Spring Boot uses.
Example
public record CreateOrder(@NotBlank String sku, @Positive int quantity) { }Related terms
- field error — A validation failure tied to one input field, reported with the field name and a message such as "must not be blank".
- request binding — A framework converting parts of an HTTP request, such as path variables, query parameters, headers and the body, into typed method arguments.
- Jakarta EE — The family of Java enterprise specifications, run by the Eclipse Foundation, that defines standard APIs such as Persistence, Validation and Annotations.
- error envelope — A fixed wrapper shape for every error response, so clients can read any error the same way.
Taught in
- Configuration And Profiles — Modern Java: Virtual Threads & High-Throughput Services
- Reading The Request — Modern Java: Virtual Threads & High-Throughput Services
- Validation — Modern Java: Virtual Threads & High-Throughput Services