wowprompt

Input validation schema from a form or API payload

Writes a validation schema for a form or API request in the library you use, such as Zod, Pydantic, Joi or JSON Schema, with types, limits, formats and clear error messages. Use it when an endpoint or form accepts user input and the checks are scattered or missing.

A table of every field with type, required flag, limits and error message, followed by the schema code and a set of valid and invalid sample payloads
The output this prompt produced, unedited.

The prompt

Fill in these first

  • Validation library and language: [e.g. Zod in TypeScript, Pydantic v2 in Python, JSON Schema draft 2020-12]
  • Where it runs: [browser form, API server, or both]
  • Fields: [paste a sample payload, a form description or a database table, with any business rules]
  • Rules you already know: [e.g. phone must be a 10-digit Indian mobile number, age 18 or over, at most 5 tags]
  • How errors are shown: [e.g. per-field message under the input, or a JSON list of errors]

Task

Write a schema that accepts every valid input, rejects everything else with a clear message, and strips fields that are not expected.

Output format

  1. | Field | Type | Required | Limits or format | Error message |
  2. The schema in one fenced code block, ready to import.
  3. Three valid sample payloads and five invalid ones, each with the error it should produce.
  4. Notes on anything to check on the server even when the browser already validates.

Rules

  • Set a maximum length on every string and a range on every number.
  • Trim whitespace and normalise case where it matters, such as email.
  • Reject unknown fields by default unless told otherwise.
  • Never rely on browser validation alone; the server schema is the one that counts.
  • Error messages tell the user how to fix the input and never echo back raw input or internal details.

Example

| email | string | yes | valid email, max 254 characters, trimmed and lower-cased | "Enter a valid email address, such as name@example.com." |

input validationzod schemapydantic modeljson schemaform validationapi request validation

How to run this

Copy the prompt and paste it into Gemini, then set the aspect ratio to 3:4. No reference photo is needed for this one.

The prompt is written in Markdown with each part under its own heading, which is what the copy action hands over. Change one section at a time, keeping the rest intact, so you can tell which change did the work.

Related prompts

All productivity