Skip to main content
πŸ”’ Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial β†’
⚑
← Coursesβ€ΊFastAPI ProductionModule 1 Β· Basics + Pydantic Β· Recapβ€ΊπŸŽ― Review: FastAPI module 1 recapscenario22 / 105
+80 XP
Task
Build a small `validate_order(payload)` helper that ties 4 module-1 ideas together: 1. **Required field** β€” `qty` must be present. 2. **Type check** β€” `qty` must be int (reject strings, floats, bools). 3. **Value validation** β€” `qty` must be > 0. 4. **Response shape** β€” on success return `{"ok": True, "qty": N}`; on failure return `{"ok": False, "error": "<reason>"}`. Fill the `# TODO` blocks. The harness prints results for valid / missing / negative / wrong-type / float cases.
✏️ Write your code here
🐍
Loading Python...
One-time download (~1 MB). Then it runs instantly.
πŸ“Š Result
Press Run to see result...

πŸ’¬ Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…