Pydantic Validation

Data validation, data parsing, configuration management, and type coercion using Pydantic.

Lord1Egypt Updated 2 repo stars

File contents

Pydantic Validation

Overview

Pydantic is the most widely used data validation library for Python, enforcing type hints at runtime.

When to Use This Skill

Use to validate configuration files, API payloads, or parse outputs from AI agents.

Quick Start (with runnable code examples)

from pydantic import BaseModel, Field, EmailStr

class UserProfile(BaseModel):
    id: int
    name: str = Field(min_length=2)
    email: EmailStr
    is_active: bool = True

user = UserProfile(id=1, name="Akim", email="akim.221992@gmail.com")
print(user.model_dump())

Advanced Usage

Set up custom validators (@field_validator), dynamic model schemas, and base settings management.

Key References

Dependencies

  • pydantic[email]>=2.0.0

Lord1Egypt/ai-skillforge/tree/main/js/skills/gemini/pydantic-validation commit e15caf33a3

Frequently asked questions

npx skillmds@latest add lord1egypt/pydantic-validation-2