Add validation module: Bean Validation on Spring Boot 4.2.0 with Hibernate Validator 9.1.6, built-in and custom constraints, groups, method validation, ProblemDetail errors, message i18n, JPA integration and tests, with real transcripts

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b4RzcCS5JCAgcxLz7T
This commit is contained in:
Claude
2026-12-05 16:18:03 +05:30
parent a95f042051
commit 417903fbc2
78 changed files with 2279 additions and 0 deletions
@@ -0,0 +1,27 @@
== POST /users {"username":"admin","email":"nope","age":15,"roles":["dev"],"address":{"city":"Mumbai","pinCode":"4007"}}
HTTP 400 application/problem+json
{"detail":"Invalid request content.","status":400,"title":"Bad Request","errors":[{"field":"address.pinCode","code":"Pattern","message":"PIN code must be 6 digits"},{"field":"age","code":"Min","message":"Minimum age is 18"},{"field":"email","code":"Email","message":"Enter a work e-mail such as [email protected]"},{"field":"username","code":"AvailableUsername","message":"That username is taken"}]}
== GET /users?size=0&sort=name
HTTP 400 application/problem+json
{"detail":"Validation failure","status":400,"title":"Bad Request","errors":[{"field":"size","code":"Min","message":"must be greater than or equal to 1"}]}
== POST /contacts/bulk [{"email":"[email protected]","message":"This is spam."}]
HTTP 400 application/problem+json
{"detail":"Validation failure","status":400,"title":"Bad Request","errors":[{"field":"[0].message","code":"SpamMessageCheck","message":"Message contains 'spam' and must be at least 50 characters long."}]}
== POST /password {"password":"correct-horse","confirmation":"nope"}
HTTP 400 application/problem+json
{"detail":"Invalid request content.","status":400,"title":"Bad Request","errors":[{"field":null,"code":"PasswordsMatch","message":"Passwords do not match"}]}
== POST /users/internal {}
HTTP 400 application/problem+json
{"detail":"Validation failure","status":400,"title":"Bad Request","errors":[{"field":"createUser.creatorToken","code":"NotBlank","message":"must not be blank"},{"field":"createUser.user.address","code":"NotNull","message":"must not be null"},{"field":"createUser.user.age","code":"NotNull","message":"must not be null"},{"field":"createUser.user.email","code":"NotBlank","message":"must not be blank"},{"field":"createUser.user.roles","code":"NotEmpty","message":"must not be empty"},{"field":"createUser.user.username","code":"NotBlank","message":"Username is required"}]}
== POST /bookings {"startDate":"2026-05-10","endDate":"2026-05-01"}
HTTP 400 application/problem+json
{"detail":"Invalid request content.","status":400,"title":"Bad Request","errors":[{"field":"endDate","code":"DateRange","message":"End date must be after start date"}]}
== POST /bookings {"startDate":"10/05/2026"}
HTTP 400 application/problem+json
{"detail":"Failed to read request","status":400,"title":"Bad Request"}