Validation Articles
Articles covering Spring Boot validation including input validation, group validation, and method-level validation.
-
How to Validate List<DTO>, @RequestParam, and @PathVariable in Spring Boot - Why @Valid Doesn't Work and How to Handle the 3 Exceptions
A reverse-lookup guide to why element validation of a List-typed DTO annotated with @Valid, or @Min on @RequestParam/@PathVariable, doesn't work in Spring Boot 3.x, and how to fix it. Covers the differences between the 3 exceptions, unified error responses with @RestControllerAdvice, and indexed messages in the users[1].name format.
-
Spring Boot Validation Annotations Cheat Sheet - From the Differences Between @NotNull/@NotEmpty/@NotBlank to Custom Messages
A cheat sheet of the standard constraint annotations available in Spring Boot 3.x (Jakarta Bean Validation 3.0), listing each one's target types, behavior on null, and default message. Covers the differences between @NotNull/@NotEmpty/@NotBlank, @Size vs @Length, choosing between numeric, date-time, and string constraints, Hibernate Validator-specific constraints, and overriding messages with localized text via ValidationMessages.properties or messages.properties.
-
How to Validate Spring Boot @ConfigurationProperties with Bean Validation - A Fail Fast Implementation Guide for Detecting Configuration Errors at Startup
Learn how to combine Spring Boot @ConfigurationProperties with Bean Validation (@Validated/@NotBlank/@Pattern) to catch configuration errors at application startup, before they become production incidents. Covers nested validation with @Valid propagation, how to read startup error messages, and lightweight testing with ApplicationContextRunner, all with implementation examples.
-
How to Implement Internationalization (i18n) in Spring Boot - Using MessageSource and LocaleResolver
A practical guide to implementing internationalization (i18n) in Spring Boot REST APIs. Covers language switching via the Accept-Language header, locale fallback with messages.properties, configuring MessageSource and AcceptHeaderLocaleResolver, localizing @Valid validation error messages, and returning multilingual error responses with @RestControllerAdvice, all in one end-to-end walkthrough.
-
How to Create Custom Validation Annotations in Spring Boot - @Constraint/ConstraintValidator Implementation Guide
A step-by-step guide to creating custom validations with @Constraint and ConstraintValidator, covering three patterns: phone number format, email duplication check (using DI), and password confirmation (cross-field). Encapsulate rules that @NotBlank / @Pattern cannot handle into reusable annotations and consolidate validation logic scattered across the Service layer.
-
How to Implement Group Validation and Method Validation with Spring Boot's @Validated Annotation
A step-by-step guide to safely integrating group validation and Service-layer method validation using Spring Boot's @Validated, covering the differences from @Valid and exception handling.
-
How to Implement Validation Simply with the Spring Boot @Valid Annotation - Usage and Error Handling
A concise guide with code to using the Spring Boot @Valid annotation. Covers automatic validation with @RequestBody, key constraints such as @NotBlank/@Email/@Size, recursive validation of nested DTOs, the difference from @Validated, and standardizing error responses for MethodArgumentNotValidException with implementation examples.