request-validation

Validate API inputs with Zod and Pydantic schemas and middleware.

Updated Jan 30, 2026
One-click install
npx skills add https://github.com/jrmatherly/metorial-workspace --skill request-validation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: request-validation
Source: https://github.com/jrmatherly/metorial-workspace/tree/main/.github/skills/request-validation
Command: npx skills add https://github.com/jrmatherly/metorial-workspace --skill request-validation

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers enforce strict input validation for APIs by providing ready-made schemas and validation middleware for both TypeScript (Zod) and Python (Pydantic), reducing runtime errors and security risks.

Core Features & Use Cases

  • Schema definitions: Provides TS (Zod) and Python (Pydantic) schemas for common inputs (email, password, name, role) with type-safe inference.
  • Validation middleware / routing integration: Integrates with Express, FastAPI, and similar frameworks to validate body, query, and route params, returning structured error messages.
  • Error handling & defaults: Returns consistent errors with field-level messages and applies sensible defaults to optional fields.

Quick Start

Install the required dependencies for Node.js (npm/yarn) and Python environments, import the schemas into your API, and attach the validation middleware to routes to begin validating inputs immediately.

Frequently Asked Questions about request-validation

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

FAQPage Schema
How do I validate API requests using Zod or Pydantic schemas?

You validate API requests by defining Zod or Pydantic schemas and attaching validation middleware to routes, which checks inputs and returns structured field-level error messages for invalid data.

Can I use validation middleware with Express and FastAPI?

Yes, validation middleware integrates with Express and FastAPI to validate body, query, and route parameters, returning structured error messages and applying sensible defaults to optional fields.

What is the best way to return consistent API validation errors?

The best way to return consistent API validation errors is using middleware that generates structured error responses with field-level messages, ensuring clients receive clear feedback on failed input constraints.

How do I apply defaults to optional fields during API input sanitization?

You apply defaults to optional fields during API input sanitization by configuring schema definitions to automatically populate missing optional query or body parameters with sensible default values before processing.

Why do I need schema validation for API user creation and updates?

You need schema validation for API user creation and updates to enforce strict input constraints like email and password formats, reducing runtime errors and preventing security risks from malformed payloads.