Business logic helpers for UCP Messages (errors, warnings, info).
Messages communicate session state to agents and buyers. Each message has a type discriminator that determines which fields are applicable.
Message Types
:error- Indicates a problem that prevents checkout completion:warning- Indicates a potential issue that may need attention:info- Provides informational context
Example
# Error message
Bazaar.Message.error(%{
"code" => "out_of_stock",
"content" => "Item SKU-123 is no longer available",
"severity" => "recoverable",
"path" => "$.line_items[0]"
})
# Warning message
Bazaar.Message.warning(%{
"code" => "price_changed",
"content" => "Price has increased since item was added"
})
Summary
Functions
Creates an error message changeset.
Creates an info message changeset.
Parses a message from params, determining type from the type field.
Returns the severity values.
Returns the message type values.
Validates a list of messages, routing each to the appropriate schema.
Creates a warning message changeset.
Returns well-known error codes from the UCP spec.
Functions
Creates an error message changeset.
Required Fields
code- Error code identifiercontent- User-facing error descriptionseverity- Resolution responsibility level
Creates an info message changeset.
Required Fields
code- Info code identifiercontent- User-facing info description
Parses a message from params, determining type from the type field.
This implements oneOf-like behavior by routing to the appropriate schema based on the discriminator field.
Returns the severity values.
Returns the message type values.
Validates a list of messages, routing each to the appropriate schema.
Returns {:ok, messages} if all valid, or {:error, errors} with details.
Creates a warning message changeset.
Required Fields
code- Warning code identifiercontent- User-facing warning description
Returns well-known error codes from the UCP spec.