API Request Validation Schema Builder

Create comprehensive request validation schemas with JSON Schema, Zod, or Joi for API endpoints.

6/11/2026
Prompt
You are a backend developer specializing in API input validation and data integrity.

## CONTEXT
I need to create validation schemas for my API endpoints.

**Requirements:**
- Framework: {{FRAMEWORK}}
- Validation Library: {{VALIDATION_LIB}}
- Endpoints: {{ENDPOINTS}}
- Data Types: {{DATA_TYPES}}

## TASK
Create comprehensive validation schemas:

### 1. JSON SCHEMA
```json
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": ["field1", "field2"],
  "properties": {
    "field1": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100,
      "pattern": "^[a-zA-Z]+$"
    },
    "email": {
      "type": "string",
      "format": "email"
    }
  },
  "additionalProperties": false
}
```

### 2. ZOD SCHEMA (TypeScript)
```typescript
const createUserSchema = z.object({
  email: z.string().email(),
  name: z.string().min(1).max(100),
  age: z.number().int().min(0).max(150).optional(),
});
```

### 3. JOI SCHEMA (Node.js)
```javascript
const schema = Joi.object({
  email: Joi.string().email().required(),
  name: Joi.string().min(1).max(100).required(),
});
```

### 4. COMMON VALIDATIONS
- Email, URL, UUID formats
- Date/time validation
- Enum values
- Nested objects
- Arrays with constraints
- Conditional validation
- Custom validators

### 5. ERROR MESSAGES
Customized, user-friendly error messages.

### 6. MIDDLEWARE INTEGRATION
Code for integrating validation in your framework.

Or press ⌘C to copy

Variables (8)

Replace these placeholders with your own content before using the prompt.

[{FRAMEWORK][{VALIDATION_LIB][{ENDPOINTS][{DATA_TYPES]{ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "required": ["field1", "field2"], "properties": { "field1": { "type": "string", "minLength": 1, "maxLength": 100, "pattern": "^[a-zA-Z]+$" }{ "type": "string", "format": "email" }{ email: z.string().email(), name: z.string().min(1).max(100), age: z.number().int().min(0).max(150).optional(), }{ email: Joi.string().email().required(), name: Joi.string().min(1).max(100).required(), }

Ready to use?

Copy and paste into your favorite AI tool

Test this prompt live

Try it in our AI Playground with Claude

Open Playground

Explore more Coding prompts

Browse Coding

Command Palette

Search for a command to run...