Claude-skill-registry api-request-validation
A skill for implementing robust API request validation in Python web frameworks like FastAPI using Pydantic. Covers Pydantic models, custom validators (email, password), field-level and cross-field validation, query/file validation, and structured error responses. Use when you need to validate incoming API requests.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/api-request-validation" ~/.claude/skills/majiayu000-claude-skill-registry-api-request-validation && rm -rf "$T"
manifest:
skills/data/api-request-validation/SKILL.mdsource content
API Request Validation Skill
Overview
This skill provides guidance and reusable components for implementing robust API request validation in Python, primarily using FastAPI and Pydantic.
It covers:
- Basic validation with Pydantic models.
- Custom validation logic for specific fields.
- Advanced validation scenarios like cross-field validation and query parameters.
- Standardized error handling for validation failures.
Getting Started
The most common validation tasks are broken down into reference files. Start with the one that best fits your needs.
- Basic Validation: If you're new to Pydantic or need to validate a simple data structure, see
.references/pydantic-models.md - Custom Rules: For validating specific formats like emails or password strength, see
.references/custom-validators.md - Complex Scenarios: For validating query parameters, file uploads, or dependencies between fields, see
.references/advanced-validation.md - Error Responses: To customize how validation errors are returned to the client, see
.references/error-handling.md
Resources
references/
references/
: Guide to creating basic Pydantic models for request body validation.pydantic-models.md
: How to write custom validator functions for fields.custom-validators.md
: Covers cross-field validation, query parameters, and file uploads.advanced-validation.md
: Instructions for creating a custom FastAPI exception handler for validation errors.error-handling.md
scripts/
scripts/
: A collection of reusable Pydantic validator functions (e.g., for email, password strength).validators.py
: A pre-built FastAPI exception handler forerror_handler.py
.RequestValidationError
: A full FastAPI application demonstrating all validation techniques covered in this skill. You can run this file to see the validation in action.main_example.py