What problem does it solve?
Spring Boot endpoints and service methods often accept untrusted client input, leading to inconsistent null handling, scattered checks, and unclear error responses. This Skill centralizes Jakarta Bean Validation patterns so request DTOs, method parameters, and error handling behave predictably across your API.
Core Features & Use Cases
- DTO and record constraint validation: Use
@Valid, @Validated, and standard constraints (@NotBlank, @Email, @Size, @Past, etc.) to validate incoming payloads and nested objects.
- Custom constraint annotations and validators: Implement domain-specific rules via
@Constraint(validatedBy=...) such as phone number formats or business-date rules.
- Cross-field and service-layer validation: Apply class-level validators for multi-field rules (e.g., password confirmation matching) and enable method parameter validation using
@Validated on services.
- Group sequences and targeted validation: Use validation groups to run only the appropriate constraints for create vs update flows.
- Consistent validation error handling: Convert
MethodArgumentNotValidException and ConstraintViolationException into structured HTTP responses (e.g., ProblemDetail with field-level errors).
Quick Start
Ask for a Spring Boot controller endpoint and request record that validate input with @Valid, implement one custom annotation, add a cross-field rule, and return a ProblemDetail containing field-level errors.