Module 05 Activity
Scenario
Turn the contract into models that enforce it.
What you build
Request and response models carrying types, policy limits and cross-field rules, separate from internal shapes.
Steps
- Write the request and response models and generate the schema. Check it against the contract from Module 1.
- Confirm invalid requests never reach the handler by counting handler invocations.
- Add the policy limits - ceilings, allowed sets, minimum lengths - to the model rather than the service.
- Model any nested structure as a nested model and check the error names the nested path.
- Add one cross-field rule using a model validator.
- Confirm internal shapes are separate types from the published models.
Evidence to hand in
- The models and the generated schema.
- The handler invocation count against request count.
- Policy limits on the model.
- A nested validation error showing its path.
- The cross-field rule.
- The separation of internal and published types.
Review checklist
- The generated schema matches the Module 1 contract.
- Invalid requests demonstrably never reach the handler.
- Policy limits are on the model, not only in the service.
- Nested errors name the nested field path.
- Internal shapes are separate types from the published models.
