liveBook · Manning

Validate-only field

As explained in API Design Patterns

Validation-only mode checks whether a request is valid without applying the requested operation.

A validate-only field lets an API caller preview whether an unsafe request would succeed without applying its requested operation. Set the optional Boolean to true; otherwise the method behaves normally. section 27.0 section 27.3

Design validation requests to provide a useful, safe preview:

  • Validate as many request aspects as possible, including authorization, referential integrity, parameter formats, and relevant external services, without modifying data. section 27.3 section 27.6
  • Return errors as the real request would, such as 403 Forbidden, and populate response fields whenever they can be determined. section 27.3
  • Default validateOnly to false so ordinary requests continue to execute without requiring an extra flag. section 27.3
  • Use a safer opt-in design for catastrophic operations when omission could destroy data; a force field can require explicit execution and provide a preview otherwise. section 19.3.2

Creating a chat room

A create request can expose validation explicitly: CreateChatRoom({ resource: chatRoom, validateOnly: true }). The call checks whether creation would succeed while keeping the operation safe and idempotent; a normal request omits the field or leaves it false. section 27.3.3 section 27.3

Figure 27.2 Validation requests might still connect to other internal components.

Validation may still contact authorization, integrity, or other internal components while avoiding data modification. section 27.3

How API Design Patterns covers it

How deep it goes
Defines the Boolean contract, response fidelity, dependency checks, and dangerous-operation exception.
Examples
Uses chat-room creation, remote-service access, SQL-format checking, and criteria-based message purging as examples.
What it assumes
Assumes familiarity with API methods and unsafe operations while distinguishing validation from actual execution.
What you can do after
Evaluate whether an unsafe API request can execute without modifying the underlying system.
How it connects
Connects request validation with unsafe methods, external services, authorization, referential integrity, and idempotency.

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.