Validates data against UCP and ACP schemas.
UCP schemas (checkout, order, profile) are validated via JSV against the
bundled JSON Schema files. ACP JSON schemas (checkout_session, delegate_payment_req,
etc.) are validated via JSV against bundle schemas with $defs. The OpenAI product feed
is validated via an Ecto embedded schema changeset.
Note
This module requires the jsv dependency. Add {:jsv, "~> 0.15"} to your
mix.exs deps to use validation features.
Usage
case Bazaar.Validator.validate_checkout(checkout_data) do
{:ok, validated} -> # Data conforms to spec
{:error, errors} -> # Validation errors
end
# Or use validate/2 with any schema atom
Bazaar.Validator.validate(data, :checkout_session)Available Validators
validate_checkout/1- UCP checkout session responsevalidate_order/1- UCP order responsevalidate_profile/1- UCP discovery profilevalidate/2- Generic validation against any schema (UCP, ACP, OpenAI)
Summary
Functions
Lists all available schemas bundled with Bazaar, grouped by protocol.
Returns the raw JSON schema for a given UCP schema name.
Validates data against a specific UCP or ACP schema.
Validates data against the UCP checkout response schema.
Validates data against the UCP order schema.
Validates a UCP discovery profile (the /.well-known/ucp response).
Functions
Lists all available schemas bundled with Bazaar, grouped by protocol.
Returns the raw JSON schema for a given UCP schema name.
Validates data against a specific UCP or ACP schema.
UCP schemas
:checkout- Checkout session response:order- Order response:profile- Discovery profile
ACP schemas (from open ACP repo)
:checkout_session- Checkout session response:checkout_session_with_order- Checkout session response with order:checkout_create_req- Create checkout request:checkout_update_req- Update checkout request:checkout_complete_req- Complete checkout request:cancel_session_req- Cancel session request:delegate_payment_req- Delegate payment request:delegate_payment_resp- Delegate payment response
ACP schemas (OpenAI-specific)
:openai_product_feed- Product feed
Validates data against the UCP checkout response schema.
Returns {:ok, data} if valid, or {:error, errors} with validation errors.
Validates data against the UCP order schema.
Returns {:ok, data} if valid, or {:error, errors} with validation errors.
Validates a UCP discovery profile (the /.well-known/ucp response).
Returns {:ok, data} if valid, or {:error, errors} with validation errors.