Validation Rules & Error Copy Generator for Forms
Create precise field-level validation rules with error messages, boundary tests, and patterns users understand, ready to wire into your form or API.
Prompt Overview
Tips For You
Keep one validation rule per message. Include copy for both inline and toast notifications. Provide at least three valid and three invalid examples per field.
From Operations TeamNexusAi TechnologyProblem It Solves
Vague or inconsistent validation leads to bad data and user frustration. This prompt standardizes rules and messages before you build.
Field-by-field rules
Typed, ranged, and patterned validation per field.
Error copy system
Short, consistent, human-readable error messages.
Boundary tests
Valid/invalid examples that cover edge cases.
API error schema
Server-side error contract for exact mappings.
AI Prompt Instructions
Act as: Senior Product Designer and Validation Engineer.
Why this task matters: Strong validation protects data quality, reduces support tickets, and increases conversion by making errors fixable and human.
Important boundaries:
- Error messages must be short, specific, and helpful with one correction step.
- Cover client-side and server-side validation; align with eventual API contract.
- Include locale, PII, and accessibility considerations.
User inputs:
[Form purpose]
[List of fields with any known constraints]
[Target locale]
[Risky/regulated fields (e.g., PII, payments)]
Objectives:
1) Define validation per field (type, length, pattern, range, required, uniqueness).
2) Draft user-facing error messages and inline help.
3) Provide boundary test cases (valid/invalid examples).
4) Recommend server-side checks and rate limits for abuse prevention.
Analysis workflow:
1) Classify fields by type and risk level.
2) For each field, specify validation rules and examples.
3) Design consistent error copy style (tense, tone, punctuation).
4) Add cross-field rules (e.g., start_date <= end_date).
5) Propose API response schema for errors.
Required output format:
- FieldValidations[{field, rules, examples_valid[], examples_invalid[], error_copy, inline_help}]
- CrossFieldRules[]
- APIErrorSchema {code, field, message, hint, doc_url}
- AbusePrevention {rate_limits, captcha_when, logging}
Quality controls:
- Messages are 1–2 short sentences, plain language.
- Examples include edge cases (nulls, max length - 1, unicode, emoji if relevant).
Verification checklist:
- Can a developer implement these rules without guessing?
- Are server errors mapped 1:1 to field names?
Final instruction: Output the specification first, then a short playbook for QA to verify rules with sample data.
Expected Outcome
email: type email, max 254, required true, error "Enter a valid email like name@company.com"; date_range: start <= end with clear messages for each failure; API error schema with code, field, message, hint.
Implementation Journey
Draft rules in Gemini
Open Gemini and paste your form’s purpose, fields, and known constraints. Request field-by-field validation rules with examples and user-facing error copy. Expect a specification table with consistent tone and clear patterns.
10-15 minRefine copy in ChatGPT
Paste Gemini’s output into ChatGPT and ask for tighter wording, locale checks, and accessibility improvements. Expect shorter, clearer error messages and guidance on screen reader announcements.
10-12 minImplement in your form
Translate the rules into your client and server validators. Use the provided API error schema to return consistent responses. Run the examples as QA test cases to confirm message clarity.
20-30 min
