pydantic
Package — ValidationPython 3.8+Intermediate
Data validation using Python type annotations; settings management
Quick Info
- Documentation
- Official Docs
- Python Version
- 3.8+
- Dependencies
- typing-extensions, annotated-types, pydantic-core (Rust binary)
- Install
pip install pydantic
Learn by Difficulty
Quick Example
python
# Install: pip install pydantic from pydantic import BaseModel, field_validator class User(BaseModel): name: str age: int email: str @field_validator("age") @classmethod def validate_age(cls, v): if v < 0 or v > 150: raise ValueError("Invalid age") return v user = User(name="Alice", age=30, email="alice@example.com") print(user.model_dump())
pydantic is a third-party package. Data validation using Python type annotations; settings management. Install with: pip install pydantic
Try in PlaygroundTags
packagevalidationdatatypetype-hintssettings
Related Items
attrs
Package — Validation
Classes without boilerplate: attributes with validation
marshmallow
Package — Validation
Object serialization/deserialization and validation
dataclasses
Stdlib — Data
Decorator for auto-generating class boilerplate (__init__, __repr__, etc.)
fastapi
Package — Web Framework
Modern async API framework with automatic OpenAPI docs and Pydantic validation
sqlmodel
Package — Database
SQL databases with Pydantic and SQLAlchemy (by FastAPI creator)
jsonschema
Package — Validation
Validate JSON data against JSON Schema specifications