- Classify four fixture requests by syntax, shape and business-rule validity.
- Check that rejected requests do not create an order or expose an internal exception.
- Ask AI for a missed boundary case and verify it against the explicit contract.
Parsing JSON does not establish that a request contains the fields your application needs. AI-generated handlers often blur syntax, structure and business rules. Use a small fictional request to define these checks separately, and verify failures without exposing internal error details.
Separate three different questions
First ask whether the bytes form valid JSON. Next ask whether the result is an object with the expected field types. Finally ask whether the values meet the application rule. In the fixture, quantity must be an integer from one through nine and productId must be a nonempty string. The JSON string "3" is syntactically valid but is not the same type as numeric3. A correct parser can therefore be followed by a necessary validation rejection.
Reject at the authoritative interface
Put the check in the server handler or trusted processing boundary, not only in an HTML input control. The browser’s min and max attributes improve usability but can be bypassed by a separate client. Ask AI to propose readable error categories and then check that they do not reveal stack traces or secrets. Decide how unknown fields are handled explicitly; silently accepting an unexpected role field can become dangerous if another layer later begins using it.
Test useful and hostile-looking data as data
Create a valid request, a wrong-type request, an out-of-range request and an object with an extra field. Keep strings containing markup inert throughout display and logging. The test should assert both the status category and the absence of processing side effects after rejection. Explain why each decision belongs to syntax, structure or application policy. This produces a reusable review method rather than an unexplained validation snippet copied from an assistant response.
Fictional worked example — Quantity request
Supplied input
{"productId":"P-3","quantity":"3"}Example result to inspect
Rejected: quantity must be an integer
The document parses, but its quantity is a string and fails the stated structural contract.
This is an authored teaching example, not a recorded live provider run or an independent performance test.
Make the idea concrete.
- Classify four fixture requests by syntax, shape and business-rule validity.
- Check that rejected requests do not create an order or expose an internal exception.
- Ask AI for a missed boundary case and verify it against the explicit contract.
What a useful outcome looks like
Parsing establishes syntax; structure, authorization and application rules still require independent checks.
Ask for reasoning you can verify.
Use fictional or permitted data. This is a copyable brief for a separate approved model; no model is called from this article.
Help me review this fictional coding with ai exercise: Separate parsing, structural validation and application rules in generated code. I will supply the original input, my expected result and the actual transformation. Explain quantity type, identify unsupported assumptions about rejected side effects, and propose one bounded negative control. Keep observations separate from hypotheses; do not invent output or act on external systems.
Turn reading into a reviewed checkpoint.
Complete the manual exercise, review each item, then answer the evidence question. This records self-study, not independent assessment of expertise.
Review the checklist and pass the question to save this lesson.
Primary references
References support further checking; cited organizations do not endorse AgentX. This guide is original AI-assisted educational content with illustrative examples. Read the editorial policy or report a correction.
Continue with a related task.
Read the contract before asking for code
Map callers, inputs and invariants before requesting a change.
Request a minimal diff with explicit exclusions
Keep an AI-assisted patch focused enough to review and revert.
Test the requirement rather than the generated implementation
Use independent examples to challenge an AI-written function.