Skip to main content

Chapter 55 Quiz

Before taking the quiz, verify that you can do each of these without looking at the lessons:

  • Explain the trust gap: Describe why @dataclass accepts wrong types at runtime and when pyright cannot help
  • Define a BaseModel: Write a Pydantic model with typed fields and create valid and invalid instances
  • Add Field constraints: Use min_length, max_length, gt, ge, lt, le to enforce value rules
  • Catch ValidationError: Write try/except ValidationError and access error details with e.errors()
  • Serialize and parse: Convert a model to dict/JSON and parse JSON into a validated model
  • Apply the boundary pattern: Explain why Pydantic guards the edges and dataclasses live inside

If any feel uncertain, revisit the specific lesson before continuing.

Test your understanding of Pydantic validation by solving real-world scenarios involving type checking, constraints, serialization, and boundary design.

Checking access...