Pydantic v2 Data Validation and Modeling

Parent: Programming Languages · researched 2026-06-01T02:04:27.586Z· 10 sources · 10 concepts · skill pydantic-v2

> Reference file — part of the programming-languages hub. Created via /dr research (Pydantic v2 data validation and modeling).

Overview

Overview

1. BaseModel and field definitions

2. Validators — field, model, and the before/after/wrap modes

3. Strict vs lax mode and ConfigDict

4. Serialization — model_dump, JSON, aliases, computed fields

5. TypeAdapter — validation/serialization without a BaseModel

6. Discriminated (tagged) unions

7. pydantic-settings — typed configuration

Tools / Frameworks

Methodology — choosing the right tool

Practical Patterns

Anti-Patterns (and the fix)

Troubleshooting

References

Children

Frontier under this node: BaseModel and field definitions (Field, Annotated constraints), Discriminated (tagged) unions, Serialization (model_dump/model_dump_json, aliases, include/exclude, computed_field, RootModel), Strict vs lax coercion and ConfigDict, TypeAdapter for non-model types, V1 to V2 migration and anti-patterns, ValidationError handling, Validators (field_validator/model_validator, before/after/wrap/plain modes), pydantic-core (Rust) architecture and performance, pydantic-settings (BaseSettings, env/.env/secrets)

← the whole tree · 3D view· how to read this page