GitHunt
GF

gflohr/e-invoice-eu-validator

Simple wrapper API around the MustangProject e-invoice validator.

licence
price
stand with

E-Invoice-EU-Validator

Minimal API wrapper around the MustangProject
validator.

Description

When issuing or receiving electronic invoices, it is a good idea to validate
them against the corresponding schemas. One software that you can use for this
purpose is MustangProject which
comes with a CLI.

The problem with the CLI is that it starts up very slowly and can validate
only one document at a time. This server offers the validation
features of MustangProject as a minimal server API. This allows performant
batch validation of invoices.

It also avoids privacy issues because the invoices do not have to be sent
over the internet to third-party services.

Generating Invoices

This project is a sister project of
E-Invoice-EU. See
there for information about how to
create electronic invoices.

Starting the Server

Released Version

Download a validator-VERSION-jar-with-dependencies.jar file from the
releases page.

Then run the server

PORT=8080 java -jar target/validator-2.21.0-jar-with-dependencies.jar

Inspect the sources if you want to run a jar file without dependencies.

In Development Mode

mvn clean install
PORT=8080 mvn compile exec:java -Dexec.mainClass=com.cantanea.validator.App

API Usage

The service has one single endpoint /validate. It takes one single URL
parameter invoice that contains the invoice file.

curl -v -X POST -Finvoice=@invoice.xml http://localhost:8080/validate

This would validate the invoice in the file invoice.xml. The hybrid
formats Factur-X resp. ZUGFeRD can also be validated:

curl -v -X POST -Finvoice=@invoice.pdf http://localhost:8080/validate

If the document is valid, you will receive a response with a status code of 200.
For invalid documents, 400 is sent.

The output is an XML validation report, for example:

<?xml version="1.0" encoding="UTF-8"?>

<validation filename="invoice.xml" datetime="2025-04-25 13:36:39">
  <xml>
    <info>
      <version>2</version>
      <profile>urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0</profile>
      <validator version="2.16.4"/>
      <rules>
        <fired>13</fired>
        <failed>0</failed>
      </rules>
      <duration unit="ms">776</duration>
    </info>
    <summary status="valid"/>
  </xml>
  <summary status="valid"/>
</validation>

For the hybrid Factur-X/ZUGFeRD formats, you will see three summaries; the
first one for the PDF validation, the second one for the validation of the
embedded XML, and the third one for that overall status:

<?xml version="1.0" encoding="UTF-8"?>

<validation filename="invoice.pdf" datetime="2025-04-25 14:36:22">
  <pdf>ValidationResult [flavour=3b, totalAssertions=6686, assertions=[], isCompliant=true]
    <info>
      <signature>unknown</signature>
      <duration unit="ms">1723</duration>
    </info>
    <summary status="valid"/>
  </pdf>  
  <xml>
    <info>
      <version>2</version>
      <profile>urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended</profile>
      <validator version="null"/>
      <rules>
        <fired>69</fired>
        <failed>0</failed>
      </rules>
      <duration unit="ms">1217</duration>
    </info>
    <summary status="valid"/>
  </xml>
  <summary status="valid"/>
</validation>

Versioning

The versions of this package follow that of
MustangProject. In other words,
when you are using version 2.16.4 of this package, it uses MustangProject
version 2.16.4 under the hood.

Copyright (C) 2025 Guido Flohr guido.flohr@cantanea.com, all
rights reserved.

This is free software available under the terms of the
WTFPL.

Disclaimer

This free software has been written with the greatest possible care, but like
all software it may contain errors. Use at your own risk! There is no
warranty and no liability.