Skip to content

Validates the German VAT-ID (Umsatzsteuer-Identifikationsnummer)

License

Notifications You must be signed in to change notification settings

rechtlogisch/ust-id

Repository files navigation

Recht logisch USt-ID banner image

Latest Version on Packagist Tests Total Downloads

ust-id

Validates the German VAT-ID (Umsatzsteuer-Identifikationsnummer, short: USt-ID)

Check digit (last digit) is validated based on ISO/IEC 7064, MOD 11,10 as documented within the meanwhile repealed "Datenträger-Verordnung über die Abgabe Zusammenfassender Meldungen – ZMDV" dated 13.05.1993 (BGBl. I S. 736).

Note

This package validates solely the syntax and check digit of the provided input. It does not confirm, that the provided USt-ID was assigned to an entrepreneur. Please use the official VIES service for that.

Installation

You can install the package via composer:

composer require rechtlogisch/ust-id

Usage

isUstIdValid('DE123456788'); // => true

or

use Rechtlogisch\UstId\UstId;

(new UstId('DE123456788'))
    ->validate() // ValidationResult::class
    ->isValid(); // => true

Validation errors

You can get a list of errors explaining why the provided input is invalid. The validate() method returns a DTO with a getErrors() method.

Note

The keys of getErrors() hold the stringified reference to the exception class. You can check for a particular error by comparing to the ::class constant. For example: Rechtlogisch\UstId\Exceptions\InvalidUstIdLength::class.

validateUstId('DE12345678')->getErrors();
// [
//   'Rechtlogisch\UstId\Exceptions\InvalidUstIdLength'
//    => 'USt-ID must be 11 characters long. Provided USt-ID is: 10 characters long.',
// ]

or

use Rechtlogisch\UstId\UstId;

(new UstId('DE12345678'))
    ->validate()
    ->getErrors();
// [
//   'Rechtlogisch\UstId\Exceptions\InvalidUstIdLength'
//    => 'USt-ID must be 11 characters long. Provided USt-ID is: 10 characters long.',
// ]

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

If you discover any security-related issues, please email open-source@rechtlogisch.de instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.