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.
You can install the package via composer:
composer require rechtlogisch/ust-id
isUstIdValid('DE123456788'); // => true
or
use Rechtlogisch\UstId\UstId;
(new UstId('DE123456788'))
->validate() // ValidationResult::class
->isValid(); // => true
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.',
// ]
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security-related issues, please email open-source@rechtlogisch.de instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.