Chapter plan
What you will complete
01Build a Stable Validation & Error ContractSeparate binding, constraint violations, business conflicts, and unexpected failures without leaking internals.Use Jakarta Validation for deterministic request-shape rulesRepresent errors with a consistent `ProblemDetail` extensionMap domain failures explicitly instead of catching `Exception` 40 min02Write Custom Constraints Without Hiding Business LogicCreate reusable cross-field validators and understand when validation groups become a maintenance cost.Keep validators deterministic and side-effect freeAttach field paths clients can act onPrefer distinct command types when create and update rules diverge 30 min03Centralize Failures with ProblemDetailTranslate exceptions at one HTTP boundary while preserving useful status, type, title, detail, and correlation data.Use narrow exception mappingsLog unexpected failures once with correlation contextNever expose stack traces or persistence implementation details 35 min
Module outcome
Design validation boundaries and one safe error vocabulary for every endpoint.
Mental model
Binding creates a candidate value; validation rejects bad shape; domain rules reject invalid decisions; exception mapping translates failure into HTTP.
Module checkpoint
API error contract
Add field, domain, conflict, and unexpected-failure responses to the task API.
- RFC 9457-style ProblemDetail payloads
- Custom constraint test
- Controller-advice integration test
Final module assessment
Ready to prove mastery?
Complete all 50 questions after finishing the module lessons and checkpoint.