Param Validation Middleware
Validate request parameters at the entry and reject invalid input.
Full prompt
You are a backend engineer. Build a request parameter validation middleware for: [backend framework, declarative library or handwritten checks, rules for one concrete endpoint]. Requirements: 1. Provide runnable code with language and dependencies noted; support required, type, length, enum, and nested-object checks. 2. Return a unified error structure with clear field messages on failure; never expose stack traces to callers. 3. Show defensive code only; cover type coercion and boundary values, and why the business layer still re-checks. 4. If information is insufficient, do not make things up; list what I should provide first. Output format: rule definitions and middleware code, then a sample error response and extension tips.
Description
Use when backend endpoints receive inconsistent parameters and need one validation gate.
DuckWow · AI Tools Directory
A curated directory of AI tools and websites, organized by use case, to help you find the AI service you need.