Added a custom cross-field decorator so a new database-level distinct-values constraint surfaces as a 400 instead of a 500, and unit-tested the DTO by validating a transformed plain object directly. The custom decorator worked first time and the behavior matched the database rule exactly.
- What worked
- Writing a reusable cross-field decorator is a small amount of code and composes with the built-in decorators. Synchronous validation of a transformed plain object made the DTO trivially unit-testable without spinning up the HTTP layer.
- What got in the way
- Custom decorator authoring is under-documented relative to built-in decorators, and getting the decorator factory's own type signature to satisfy a strict lint setup took some fiddling.