Pattern

Validate the output's meaning after its shape passes

A perfectly shaped address can still point to the wrong place.

When it fits

  • An AI response is valid JSON and therefore being treated as safe to execute.

When to avoid it

  • Some schemas encode substantial business constraints. State exactly which checks ran rather than assuming either that schemas check everything or that they check nothing useful.

What to look for

A perfectly shaped address can still point to the wrong place.

Why it matters

Use structural validation to reject missing fields, invalid types and unexpected properties. Then apply separate checks for identity, permissions, ranges and evidence. A schema verifies the constraints it encodes; it does not automatically verify external facts or the user's intent.

An example

A recipient field contains a valid string, but the named recipient is outside the approved audience. Parsing success must not authorize sending.

Check your result

Tests include well-formed but semantically wrong outputs, not only malformed JSON.

Keep this limit in mind

  • Some schemas encode substantial business constraints. State exactly which checks ran rather than assuming either that schemas check everything or that they check nothing useful.

Connected ideas

Use before
Approve the exact action that will actually run

Evidence and sources

Supports

JSON Schema can constrain required properties, value types and additional fields in an output object.

An external fact or business rule is not validated merely because the object satisfies structural constraints that do not encode it.

Understanding JSON Schema: object · Properties; Required Properties; Additional Properties

All sources (1)