Validates UBL documents against Peppol BIS Billing 3.0 rules using the peppol.helger.com validation web service.
This module provides an optional validation feature that requires the req
dependency. The validation service is provided free of charge without SLA
by Philip Helger.
Usage
# Validate an invoice
xml = UblEx.generate(%{type: :invoice, ...})
case UblEx.Validator.validate(xml, :invoice) do
{:ok, result} -> IO.puts("Valid!")
{:error, errors} -> IO.inspect(errors)
end
# Validate a credit note
xml = UblEx.generate(%{type: :credit, ...})
UblEx.Validator.validate(xml, :credit)Requirements
Add {:req, "~> 0.5.0"} to your dependencies in mix.exs to use this module.
Summary
Functions
Validates a UBL document against Peppol BIS Billing 3.0 rules.
Functions
Validates a UBL document against Peppol BIS Billing 3.0 rules.
Parameters
xml- The UBL XML document as a stringtype- The document type (:invoiceor:credit)opts- Optional keyword list::vesid- Override the default VESID for the document type:timeout- Request timeout in milliseconds (default: 30000)
Returns
{:ok, result}- Validation successful, returns parsed result map{:error, reason}- Validation failed or service error
Examples
iex> xml = File.read!("invoice.xml")
iex> UblEx.Validator.validate(xml, :invoice)
{:ok, %{success: true, errors: [], warnings: []}}