What problem does it solve?
Python applications often struggle with ensuring data correctness when receiving input from external sources. Pydantic provides robust, runtime data validation by leveraging Python type hints and a Rust-powered core to enforce constraints efficiently.
Core Features & Use Cases
- Type-safe models built with BaseModel and ConfigDict for flexible configuration
- Field and model validators to enforce custom rules and data normalization
- Serialization and deserialization with model_dump and model_validate_json equivalents, plus JSON Schema generation for OpenAPI integration
- Settings management with nested models and env var support for configuration
- Seamless integration with web frameworks (e.g., FastAPI, Django) and ORMs
- Lightweight dataclass-style usage via pydantic.dataclasses
Quick Start
Define a BaseModel subclass with typed fields and validate data by calling model_validate.