Module 05 Summary
What this module established
A request or response model is a published contract generated from one declaration - the validation, the documentation and the editor's types all come from it. Keep internal shapes in separate types so refactoring cannot alter what callers see.
Carry forward
- Put policy limits on the model. A permissive model advertising more than the system accepts means callers write code against the advertised version.
- Model nested structures as nested models. The error path names the failing field instead of saying the request was invalid.
- Field validators for single values, model validators for relationships. Both keep the rule with the type rather than in one handler.
Before moving on
Move on when invalid requests demonstrably never reach your handler and every policy limit lives on the model.
