liveBook · Manning

Validation request

As explained in API Design Patterns

A validation request is an API request that evaluates which resources satisfy criteria without applying the corresponding destructive operation.

A validation request checks whether an API operation would succeed without applying its changes. It gives users a safer preview before executing dangerous or expensive work. section 19.3 section 27.4

Design validation requests around these rules:

  • Expose an explicit Boolean field such as validateOnly, defaulting to false so ordinary requests still perform their work. section 27.2 section 27.3
  • Validate as many aspects as possible, including authorization, resource existence, referential integrity, and parameter correctness. section 27.2 section 27.3
  • Return the same errors a real execution would return, while making successful responses representative without requiring unavailable values such as server-generated identifiers. section 27.2 section 27.3
  • Preserve safety, idempotence, and side-effect freedom; skip external checks that would require real-world effects, and use safer substitutes when possible. section 27.3.1 section 27.6

Previewing a criteria-based purge

Send a purge request with its filter and force unset or false. The response supplies purgeSample identifiers and an estimated purgeCount, allowing the caller to verify the filter. If the result is correct, resend the same request with force set to true; the execution response reports the number of resources deleted. section 19.3

Figure 19.1 Interaction pattern for the purge method

Use the interaction pattern to compare the validation request with its subsequent destructive execution. section 19.3

How API Design Patterns covers it

How deep it goes
Explains request shape, validation scope, response parity, external dependencies, safety constraints, and a two-step purge workflow.
Examples
Demonstrates ChatRoom creation validation and a criteria-based purge that previews identifiers and counts before deletion.
What it assumes
Assumes familiarity with API requests and responses while teaching validation behavior, error parity, and safe handling of external services.
What you can do after
Apply it via an explicit validateOnly flag, inspect representative results, then repeat the request only when execution is intended.
How it connects
Connects request validation with authorization, referential integrity, idempotence, external dependencies, and destructive operations.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of API Design Patterns. The section links point to the parts of the book it draws on.