Skip to content
Back to skills

Pydantic

ASecurity

Pydantic models and validation. Use when: (1) Defining schemas, (2) Validating input/output, (3) Generating JSON schema.

  • 9 stars
  • 0 votes
  • 0 copies
  • 19 views
  • Added February 7, 2026
developmentpythonrustbash

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 3 files and shows the line behind each finding

Scanned February 12, 2026

npx -y skills add jiatastic/open-python-skills --skill pydantic --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Pydantic?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Pydantic
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jiatastic-pydantic/badge)](https://www.skillsdirectory.com/skills/jiatastic-pydantic)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: pydantic
description: >
  Pydantic models and validation. Use when: (1) Defining schemas,
  (2) Validating input/output, (3) Generating JSON schema.
---

# pydantic

Type-driven validation and serialization using Pydantic models.

## Overview

Pydantic validates data using Python type hints and provides rich serialization via `model_dump()` and JSON schema output.

## When to Use

- Validating request/response payloads
- Normalizing untrusted input
- Generating JSON schema for docs

## Quick Start

```bash
uv pip install pydantic
```

```python
from pydantic import BaseModel

class User(BaseModel):
    id: int
    email: str

user = User(id=1, email="a@example.com")
```

## Core Patterns

1. **Typed fields**: strict schema definitions.
2. **Field validators**: custom validation logic.
3. **Model validators**: cross-field checks.
4. **Serialization**: `model_dump()` and `model_dump_json()`.
5. **Settings**: environment-driven config via `BaseSettings`.

## Example: field_validator

```python
from pydantic import BaseModel, field_validator

class Model(BaseModel):
    name: str

    @field_validator("name")
    @classmethod
    def ensure_not_empty(cls, v: str):
        if not v:
            raise ValueError("name required")
        return v
```

## Example: model_validate + model_dump

```python
from pydantic import BaseModel

class Model(BaseModel):
    foo: int

model = Model.model_validate({"foo": 1})
print(model.model_dump())
```

## Troubleshooting

- **Coercion surprises**: use strict types if needed
- **Slow validators**: keep them minimal
- **Mutable defaults**: use `default_factory`

## References

- https://docs.pydantic.dev/

Files in this skill

  • SKILL.md1.6 KB
  • references/pitfalls.md448 B
  • references/quickstart.md589 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.