greenter/ubl-validator

OASIS Universal Business Language Schema Validator UBL v2.0, UBL v2.1

Maintainers

👁 giansalex

Package info

github.com/thegreenter/ubl-validator

pkg:composer/greenter/ubl-validator

Statistics

Installs: 185 383

Dependents: 9

Suggesters: 0

Stars: 15

Open Issues: 0

v2.2.0 2022-12-19 17:10 UTC

Requires

  • php: >=5.5.9
  • ext-dom: *
  • ext-libxml: *

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 3de54fbf07b2539ca22fbb88e623153682fbc15a

  • Giancarlos Salas <giansalex.woop@gmail.com>

validatorinvoiceublgreenter

This package is auto-updated.

Last update: 2026-05-20 00:48:23 UTC


README

👁 Github Actions
👁 Coverage Status
👁 Codacy Badge
👁 Mutation Badge

OASIS Universal Business Language (UBL) Schema Validator.

Install

Via Composer from packagist.org.

composer require greenter/ubl-validator

Examples

Simple usage.

use Greenter\Ubl\UblValidator;

$xml = file_get_contents('20000000001-01-F001-1.xml');

$validator = new UblValidator();

if ($validator->isValid($xml)) {
 echo 'Success!!!';
} else {
 echo $validator->getError();
}

Above example follows next steps:

  • Resolve <cbc:UBLVersionID>
  • Find XSD file in base directory
  • Run schemaValidate and gets result

Change UBL XSD directory

This package not include all UBL xsd, but you can add others xsd directory and use other UBL version.

use Greenter\Ubl\UblValidator;
use Greenter\Ubl\Resolver\UblPathResolver;

$ubl = new UblValidator();
$ubl->pathResolver = new UblPathResolver();
$ubl->pathResolver->baseDirectory = './my-ubl-xsd';

echo $ubl->isValid('<Invoice ...>');

/my-ubl-xsd directory follows this structure:

\my-ubl-xsd
│
├─2.1/
│ ├─ common/
│ └─ maindoc/
│
├─2.2/
│ ├─ common/
│ └─ maindoc/

You can download UBL xsd from oasis-open