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

Taught in

References