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.
- 20 lessons
0 of 20 lessons passed
Lessons
Progress and your code are kept in this browser only.
- Parse a boundary with BaseModel
- Choose strict validation deliberately
- Constrain fields with Field
- Reuse constraints with Annotated
- Read structured validation errors
- Distinguish missing from nullable
- Create independent default containers
- Reject unknown keys at a boundary
- Validate nested collections
- Separate input names from output names
- Normalize input before type validation
- Validate a parsed field value
- Check relationships between fields
- Select a model with a discriminator
- Validate a type without a wrapper model
- Give a root collection model behaviour
- Serialize Python values for JSON
- Expose derived data with computed_field
- Keep invariants when fields change
- Derive a schema from the validated model