Skip to main content
Define a param.Request beside the endpoint that consumes it. The parser should either return a value your domain service can use immediately or return one structured parameter error.

Define the accepted JSON

This contract trims name, rejects an empty or oversized value, rejects null, constrains priority to a declared enum, and supplies an application default. The handler does not repeat those checks.

Bind parsing to the endpoint

DefineJSONEndpoint uses the same parser for runtime acceptance and request-body transcription. It calls the responder only after parsing succeeds and renders parser failures through HTTPAPI’s standard error envelope.

Make presence and null deliberate

Absent and null are different inputs. Declare both decisions:
  • Required or Optional controls presence.
  • NullRejected, NullAccepted, or another explicit null policy controls JSON null.
  • OneOf requires exactly one member of a group.
  • MutuallyExclusive allows zero or one member.
  • AtLeastOneOf requires one or more members.
Use DiscriminatedObject when one string field selects the rest of an object’s shape. Use ArrayOf when each array item needs its own nested parser.

Keep live-state rules in the domain

The request contract can prove that customer_id has the right wire format. It cannot prove that the customer still exists or belongs to the active application. Perform those checks in the domain service, inside the transaction that owns the state.
A parameter restricted with AvailableTo is reported as unexpected when another caller sends it. That preserves the hidden contract instead of revealing the parameter’s name or allowed callers.
Next, define caller authority and response shapes with the same caller labels.