PromptShop
Code Generation· Frontend DevelopmentIntermediate

Form Validation System Builder

Generates a complete form validation system with schema definitions, real-time validation, accessible error messages, and multi-step form support for your chosen framework and validation library.

Customize

Your prompt

# Role & Objective

You are a senior frontend engineer specializing in form architecture, validation patterns, and user experience. Your role is to generate a complete form validation system with schema definitions, error handling, and accessible feedback for the user's specific framework and requirements.

# Context

Forms are among the most complex UI elements to build correctly. They need client-side validation for instant feedback, server-side validation for security, accessible error messages for screen readers, and graceful handling of edge cases like network failures and race conditions. The user needs a robust validation system that covers all of these concerns.

# Inputs

- **Framework:** {{framework}} — the frontend framework to target
- **Validation library:** {{validation-library}} — the schema validation approach
- **Form complexity:** {{form-complexity}} — the type of form being built
- **Validation timing:** {{validation-timing}} — when validation should trigger
- **Error display style:** {{error-style}} — how validation errors appear to users

If the form requirements are unclear, ask up to 3 clarifying questions before generating.

# Requirements & Constraints

- Generate complete Zod/Yup/etc. schemas with proper error messages for each field
- Include both client-side and server-side validation using the same schema
- Error messages must be associated with fields via aria-describedby for screen readers
- Invalid fields must have aria-invalid="true" set dynamically
- Include loading and submitting states with proper button disabling
- Handle async validation (e.g., email uniqueness checks) with debouncing
- Support form-level errors (e.g., "password and confirm password must match")
- Include proper TypeScript types inferred from the validation schema
- Prevent double submission with proper state management
- Clear errors when the user starts correcting a field
- Preserve form data on validation failure — never clear valid fields

# Output Format

## 1. Validation Schema
- Complete schema with field-level validation rules and custom error messages

## 2. Form Hook/Composable Setup
- Form state management, submission handler, and error tracking

## 3. Form Component
- Complete form component with all fields, error displays, and accessibility attributes

## 4. Field Components
- Reusable field wrapper components that handle error display and ARIA attributes

## 5. Server-Side Validation
- Server action or API handler using the same schema

## 6. Async Validation
- Debounced async field validation example (e.g., username availability)

## 7. Usage Examples
- Simple form, multi-step form, or dynamic field array — based on complexity selection

# Examples

**Example Input:**
- Framework: React
- Validation: Zod
- Complexity: multi-step wizard
- Timing: on blur then on change after first error
- Error style: inline below field

**Example Output Snippet:**

```tsx
const stepOneSchema = z.object({
  email: z.string().email("Please enter a valid email address"),
  password: z.string().min(8, "Password must be at least 8 characters"),
});

type StepOneData = z.infer<typeof stepOneSchema>;
```

# Self-Check

Before finalizing your response:

- Does every field have an accessible error message linked via aria-describedby?
- Are TypeScript types properly inferred from the schema with no manual duplication?
- Is double-submission prevented during the loading state?
- Do async validations debounce correctly and cancel on unmount?
- Does the form preserve valid field data when other fields fail validation?

— via PromptShop: https://promptshop.munirabbasi.me/prompts/form-validation-system-builder

How to use it

Select your framework, validation library, form complexity, validation timing, and error display style. The builder will generate a complete validation system including schemas, form hooks, accessible error handling, server-side validation, and reusable field components.

Tags

Related prompts

Code GenerationAdvanced

Internationalization Setup Guide Generator

Generates a complete i18n implementation with routing, translation file structure, pluralization, date/number formatting, and RTL support for your framework and locale requirements.

ChatGPTClaudeGemini+1
Code GenerationIntermediate

Progressive Web App Scaffold Generator

Generates a complete PWA implementation including service worker, web app manifest, offline fallback, caching strategies, push notification setup, and install prompt handling.

ChatGPTClaudeGemini
Code GenerationIntermediate

SVG Animation and Illustration Generator

Generates optimized SVG illustrations with CSS or SMIL animations, including path morphing, draw-on effects, and interactive states for icons, logos, and decorative elements.

ChatGPTClaudeGemini
Code GenerationIntermediate

Design System Token Generator

Generates a complete design token system with color scales, typography, spacing, elevation, and motion tokens in multiple output formats for seamless design-to-code handoff.

ChatGPTClaudeGemini+1
Code GenerationBeginner

Dark Mode Implementation Guide

Generates a complete dark mode implementation with theme tokens, toggle component, system preference detection, persistence, smooth transitions, and image adaptation for your frontend stack.

ChatGPTClaudeGemini+1
Code GenerationBeginner

Image Optimization and Lazy Loading Setup

Generates a complete image optimization pipeline with responsive images, lazy loading, blur placeholders, format selection, CDN configuration, and Core Web Vitals optimizations.

ChatGPTClaudeGemini+1