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
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 andnull are different inputs. Declare both decisions:
RequiredorOptionalcontrols presence.NullRejected,NullAccepted, or another explicit null policy controls JSONnull.OneOfrequires exactly one member of a group.MutuallyExclusiveallows zero or one member.AtLeastOneOfrequires one or more members.
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 thatcustomer_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.