Pydantic Data Validation
Validate records with Pydantic models. Builds field and model validators, nested models, and batch validation patterns to enforce types and business rules at the edges of your data pipelines and APIs.
This skill uses Pydantic for record-level data validation. It defines models with typed fields, field_validator and model_validator rules, nested and optional models with defaults, and batch validation over collections of records. Covers coercion, custom error messages, and separating valid rows from rejects so ingestion stays clean.
When to use
Use when validating records with Pydantic, writing field or model validators, modeling nested payloads, or batch-validating rows during ingestion or API request handling.
Examples
Model with validators
Enforce field rules
Write a Pydantic model for a user signup with an email field validator and a model validator that requires either a phone or a backup email
Batch validate rows
Split valid vs rejects
Validate this list of dict records against my Pydantic model and return two lists: parsed models and rows that failed with their errors
Nested payload
Model related objects
Model an order with a nested list of line items and a shipping address that defaults to the billing address in Pydantic