Validation
Validate invoices before sending to catch errors instantly — no network call needed.
Client-side Validation
The SDK includes a built-in validator that checks your invoice against Peppol BIS 3.0 business rules before making any API call. This catches errors instantly and saves you a round-trip to the server.
How It Works
Call peppol.validate() with the same payload you'd pass to
peppol.invoices.send(). The method returns a result object
with valid, errors[], and warnings[].
Errors vs Warnings
- Errors — blocking issues that prevent sending. Must be fixed.
- Warnings — non-blocking suggestions for better compliance. Sending still works.
Validation is also run automatically when you call
send(). If validation fails,
a PeppolValidationError is thrown — see
Error Handling.
import { Peppol } from "@getpeppr/sdk";
const peppol = new Peppol({ apiKey: "sk_sandbox_..." });
// Validate locally before sending — catches errors instantly
const result = peppol.validate({
number: "INV-2026-042",
from: { name: "Acme BVBA", peppolId: "0208:BE0456789012", country: "BE" },
to: { name: "Globex NV", peppolId: "0208:BE0987654321", street: "Rue de la Loi 200", city: "Brussels", postalCode: "1000", country: "BE" },
lines: [
{ description: "Consulting Q1", quantity: 40, unitPrice: 125, vatRate: 21 },
],
});
if (!result.valid) {
for (const error of result.errors) {
console.error(`[${error.field}] ${error.message}`);
// e.g. "[from.vatNumber] VAT number recommended for invoices > EUR 400"
if (error.suggestion) {
console.log(` Tip: ${error.suggestion}`);
// "Add vatNumber to the seller party"
}
}
}
// Also returns warnings for non-blocking suggestions
for (const warning of result.warnings) {
console.warn(`[${warning.field}] ${warning.message}`);
}Response Format
The validation result contains structured error and warning objects with
field paths that point to the exact location of each issue.
Error Object
field— dot-notation path (e.g.from.vatNumber,lines[0].unitPrice)message— human-readable description of the issuesuggestion— optional fix recommendation
Use the
field path to highlight specific form fields in your UI,
giving users precise feedback on what to fix.
{
"valid": false,
"errors": [
{
"field": "from.vatNumber",
"message": "VAT number recommended for invoices > EUR 400",
"suggestion": "Add vatNumber to the seller party"
}
],
"warnings": [
{
"field": "paymentIban",
"message": "IBAN recommended for faster payment processing"
}
]
}