Module 05 Knowledge Check
5 questions. Pass mark 4 out of 5. Answer every question before checking the answer key below, then retry after reading the feedback.
1. A request model is…
- A. an internal convenience
- B. a published contract
- C. a database schema
- D. optional with type hints
2. Constraints on the model mean the handler…
- A. should re-check them
- B. never sees invalid input
- C. runs first
- D. must catch ValidationError
3. A refund ceiling of 500 belongs…
- A. in the service
- B. on the model, so it is in the published contract
- C. in the database
- D. in the documentation only
4. Typing a nested object as dict…
- A. is simpler
- B. loses validation, schema and the error path
- C. is faster to parse
- D. is required for flexibility
5. A rule involving two fields belongs in…
- A. a field validator
- B. a model validator
- C. the handler
- D. the router
---
Answer Key and Explanations
Check these only after attempting every question.
1. B - a published contract
Adding a required field to it breaks every existing caller.
2. B - never sees invalid input
Defensive re-checks are dead code that drifts out of step with the model.
3. B - on the model, so it is in the published contract
A permissive model advertises something more permissive than the system accepts.
4. B - loses validation, schema and the error path
The nested model names the exact failing field instead of saying the request was invalid.
5. B - a model validator
A field validator sees one value; the model validator sees the whole object.
Practical Check
Apply this module to your own work: complete the module activity for *Pydantic Models for Request and Response Contracts*, then write one sentence naming what your result shows and one naming what it does not.
Strong Answer Pattern
A strong answer names the task, the evidence used, the check performed, and the remaining limitation. It avoids "proved", "guaranteed", or "always" unless the evidence genuinely supports it.
