pydantic

Enforce Pydantic v2 patterns with ConfigDict and modern validators.

3|Updated Dec 22, 2025
One-click install
npx skills add https://github.com/JoaquinCampo/Skills --skill pydantic-joaquincampo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pydantic
Source: https://github.com/JoaquinCampo/Skills/tree/main/pydantic
Command: npx skills add https://github.com/JoaquinCampo/Skills --skill pydantic-joaquincampo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Pydantic v2 best practices and correct syntax for modern Python models, helping developers migrate from v1 patterns and write robust validation code.

Core Features & Use Cases

  • Enforces use of model_config with ConfigDict, replacing class Config with modern patterns.
  • Demonstrates replacing @validator with @field_validator and @root_validator with @model_validator.
  • Guides correct serialization via model_dump and model_dump_json, and usage of TypeAdapter for validation without models.

Quick Start

Define a Pydantic v2 model using ConfigDict and validators to validate data.

Frequently Asked Questions about pydantic

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

FAQPage Schema
How do I migrate Pydantic v1 validators to v2?

To migrate Pydantic v1 validators, replace @validator with @field_validator and @root_validator with @model_validator. This ensures your data validation models use correct v2 syntax and maintain robust validation logic.

What is the best way to configure Pydantic v2 models?

The best way to configure Pydantic v2 models is using model_config with ConfigDict. This modern pattern replaces the deprecated class Config to properly define model behavior and validation rules.

How do I serialize Pydantic models in v2?

You serialize Pydantic models in v2 using model_dump for dictionary outputs and model_dump_json for JSON strings. These modern serialization methods replace older v1 dict and json approaches.

Can I validate data in Pydantic without defining a model?

Yes, you can validate data without a model by using TypeAdapter. This allows direct validation and serialization of arbitrary Python types, providing flexible data validation across services.

Why should I update my Python API schemas to Pydantic v2?

You should update Python API schemas to Pydantic v2 to enforce modern best practices, leverage ConfigDict, and utilize updated serialization methods. It resolves v1 syntax confusion and improves backend data validation robustness.