What problem does it solve?
This Skill provides clear patterns to verify Jakarta Bean Validation annotations and custom Constraint validators at the unit-test level so validation logic is correct without booting a Spring context or hitting the database.
Core Features & Use Cases
- Validator setup: Guidance to instantiate a Validator and perform isolated validation with Validation.buildDefaultValidatorFactory().
- Constraint testing: Examples for asserting built-in constraints (@NotNull, @Email, @Min/@Max, @Size) and extracting property path, message, and invalid value.
- Custom and cross-field validators: Patterns for testing custom ConstraintValidator implementations, multi-field constraints (e.g., password match), validation groups, and parameterized invalid inputs.
- Use Case: Validate DTOs and service input objects to ensure data integrity, verify custom phone-number or password-match rules, and confirm localized messages and groups behave as expected.
Quick Start
Instantiate a Validator via the Validation factory and write focused JUnit 5 tests that assert ConstraintViolation property paths, messages, and invalid values for your DTOs and custom validators.