pydantic-v2

Design Pydantic v2 data models with validators, computed fields, and FastAPI integration.

6|2|Updated Jan 6, 2026
One-click install
npx skills add https://github.com/acaprino/claude-code-daodan --skill pydantic-v2
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pydantic-v2
Source: https://github.com/acaprino/claude-code-daodan/tree/main/plugins/python-development/skills/pydantic-v2
Command: npx skills add https://github.com/acaprino/claude-code-daodan --skill pydantic-v2

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps teams implement production-ready data validation, serialization, and migrations using Pydantic v2, addressing the challenges of moving from v1 to v2 and aligning FastAPI integrations.

Core Features & Use Cases

  • Validators: field_validator, model_validator patterns for strict, predictable validation.
  • Computed fields and performance: use computed_field and optimized serialization with model_dump and model_validate.
  • Money and typing patterns: Annotated constraints for monetary values and discriminated unions, plus condecimal alternatives.
  • Settings and FastAPI integration: settings via pydantic-settings and full request/response schema integration with FastAPI.
  • Migration guidance: a practical v1 to v2 migration checklist and upgrade practices.

Quick Start

Begin by evaluating your current models and follow the v1->v2 migration checklist to convert them and implement validators, computed fields, and FastAPI integration.

Frequently Asked Questions about pydantic-v2

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate my data models from Pydantic v1 to v2?

To migrate data models from Pydantic v1 to v2, you should follow a practical migration checklist to update validation patterns, adjust field definitions, and apply recommended upgrade practices for production systems.

What is the best way to implement field and model validators in Pydantic v2?

The best way to implement validators in Pydantic v2 is using the field_validator and model_validator patterns, which provide strict, predictable data validation for robust Python models.

Does Pydantic v2 work with FastAPI for request and response schema integration?

Yes, Pydantic v2 works with FastAPI to enable full request and response schema integration, allowing you to design robust data models for production API systems.

How do I optimize serialization and use computed fields in Pydantic v2?

You optimize serialization in Pydantic v2 by using the computed_field decorator alongside model_dump and model_validate methods to efficiently process and output data models.

Can I use Annotated typing constraints for monetary values in Pydantic v2?

Yes, you can use Annotated typing constraints in Pydantic v2 for monetary values and discriminated unions, serving as a modern alternative to previous condecimal patterns.

How do I manage application settings with pydantic-settings in v2?

You manage application settings in v2 by utilizing the pydantic-settings package, which allows you to configure and validate robust environment variables for production systems.