lib-pydantic-v2

Enforce Pydantic v2 API standards for model definition, validation, and serialization.

Updated May 20, 2025
One-click install
npx skills add https://github.com/flext-sh/flext --skill lib-pydantic-v2
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: lib-pydantic-v2
Source: https://github.com/flext-sh/flext/tree/main/.claude/skills/lib-pydantic-v2
Command: npx skills add https://github.com/flext-sh/flext --skill lib-pydantic-v2

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill enforces the correct and modern usage of Pydantic v2 across the FLEXT ecosystem, preventing the use of deprecated v1 features and ensuring robust data validation and serialization.

Core Features & Use Cases

  • Model Definition: Standardizes the creation of Pydantic models using BaseModel and ConfigDict.
  • Validation: Enforces the use of field_validator and model_validator for data integrity.
  • Serialization: Guides the use of model_dump and model_dump_json for data output.
  • Use Case: When developing a new service that handles user configurations, this Skill ensures that all configuration models are defined using Pydantic v2 best practices, preventing common errors and improving maintainability.

Quick Start

Use the lib-pydantic-v2 skill to validate a dictionary against a Pydantic model.

Frequently Asked Questions about lib-pydantic-v2

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

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

Migrate Pydantic v1 validators to v2 by replacing deprecated `@validator` with `field_validator` or `model_validator`, ensuring modern data validation standards and maintaining model integrity.

What is the best way to serialize Pydantic models in v2?

The best way to serialize Pydantic models in v2 is using `model_dump` for dictionaries and `model_dump_json` for JSON strings, replacing the deprecated v1 `.dict()` method for secure data output.

How do I configure Pydantic v2 models without class Config?

Configure Pydantic v2 models by replacing the deprecated `class Config` with `ConfigDict`, allowing strict adherence to v2 configuration standards for robust data handling and maintainability.

Does Pydantic v2 support dynamic type validation with TypeAdapter?

Pydantic v2 supports dynamic type validation with `TypeAdapter`, allowing you to validate dictionaries against non-BaseModel types and standardizing data modeling patterns securely.

Why does my Pydantic model serialization break after upgrading to v2?

Pydantic model serialization breaks after upgrading to v2 because deprecated v1 patterns like `.dict()` are banned, requiring migration to `model_dump` or `model_dump_json` for correct data output.