typespec-validation

Validate TypeSpec models with decorators and JSON Schema.

1|Updated Mar 15, 2026
One-click install
npx skills add https://github.com/hafley66/claude-research --skill typespec-validation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typespec-validation
Source: https://github.com/hafley66/claude-research/tree/main/skills/typespec-validation
Command: npx skills add https://github.com/hafley66/claude-research --skill typespec-validation

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Data validation for TypeSpec models to ensure runtime correctness through decorators, constraints, formats, and JSON Schema validation, enabling consistent data shapes and predictable errors across services.

Core Features & Use Cases

  • Validation decorators (@pattern, @minValue, @maxValue, @minLength, @maxLength)
  • Format constraints (@format for uuid, email, uri, date-time)
  • JSON Schema emission for runtime validation
  • Custom error types extending Error<T>
  • Unique item and secret field support
  • Applicable to data models, API payloads, and data processing pipelines

Quick Start

Define your TypeSpec model and apply decorators to enforce constraints and generate JSON Schema for runtime validation.

Frequently Asked Questions about typespec-validation

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

FAQPage Schema
How do I enforce runtime data validation on TypeSpec models?

Runtime data validation for TypeSpec models works by applying validation decorators like @pattern and @minValue to define constraints, then emitting JSON Schema to validate data shapes at runtime.

Can I validate format constraints like email and uuid in TypeSpec?

You can validate format constraints in TypeSpec using the @format decorator to enforce specific data formats like uuid, email, uri, and date-time on your model properties.

What is the best way to report precise validation errors from TypeSpec constraints?

The best way to report precise validation errors is by using custom error types extending Error<T>, which provides structured failure reporting when data violates TypeSpec constraints.

Does TypeSpec support unique items and secret field validation?

TypeSpec supports unique item and secret field validation using the @uniqueItems and @secret decorators to enforce array uniqueness and protect sensitive data fields.

How do I generate JSON Schema from TypeSpec for API input validation?

You generate JSON Schema from TypeSpec by applying validation decorators to your models, which automatically structures the schema constraints needed for API input validation.