Web, data & APIs · Course 3 of 8

Pydantic: validate real data

Twenty practical lessons using Pydantic 2: models, constraints, validators, nested data, unions, serialization and JSON Schema. Every example runs independently.

0 of 20 lessons passed

Start lesson 1

Lessons

Progress and your code are kept in this browser only.

  1. Parse a boundary with BaseModel
  2. Choose strict validation deliberately
  3. Constrain fields with Field
  4. Reuse constraints with Annotated
  5. Read structured validation errors
  6. Distinguish missing from nullable
  7. Create independent default containers
  8. Reject unknown keys at a boundary
  9. Validate nested collections
  10. Separate input names from output names
  11. Normalize input before type validation
  12. Validate a parsed field value
  13. Check relationships between fields
  14. Select a model with a discriminator
  15. Validate a type without a wrapper model
  16. Give a root collection model behaviour
  17. Serialize Python values for JSON
  18. Expose derived data with computed_field
  19. Keep invariants when fields change
  20. Derive a schema from the validated model

All courses