rechtlogisch / wirtschafts-id
Validates the German Wirtschafts-ID (Wirtschafts-Identifikationsnummer)
Requires
- php: ^8.1
- ext-mbstring: *
Requires (Dev)
- laravel/pint: ^1.18
- pestphp/pest: ^2.36|^3.5
- pestphp/pest-plugin-type-coverage: ^2.8|^3.1
- phpstan/phpstan: ^1.12
README
wirtschafts-id
Validates the German Wirtschafts-ID (Wirtschafts-Identifikationsnummer)
Check digit (eleventh position in normalised form) 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 Wirtschafts-ID was assigned to an entity. Please consult BZSt, if in doubt. Some insight concerning validity might be concluded based on VIES.
Installation
You can install the package via composer:
composer require rechtlogisch/wirtschafts-id
Usage
isWirtschaftsIdValid('DE123456788'); // => true
or
use Rechtlogisch\WirtschaftsId\WirtschaftsId; (new WirtschaftsId('DE123456788')) ->validate() // ValidationResult::class ->isValid(); // => true
Unterscheidungsmerkmal, short: U-Merkmal
This package supports both validation of the Wirtschafts-ID with and without the Unterscheidungsmerkmal. It is optional information after the eleventh character and separator. It consists of a hyphen and a five-digit number.
Note
Unterscheidungsmerkmal starts at 00001
and therefore 00000
is not valid.
Tip
At first all entities will receive a Wirtschafts-ID with the Unterscheidungsmerkmal -00001
. If needed, as of 2026 each economic activity (wirtschaftliche Tätigkeit) will receive a separate Unterscheidungsmerkmal, which will be incremented by one for each economic activity and linked to a tax number of the business or the permanent establishment within the responsible tax office.
Source: BZSt
Tip
Based on the form/dataset you might need to provide the Unterscheidungsmerkmal or not.
Examples
isWirtschaftsIdValid('DE123456788-00001'); // => true
or
use Rechtlogisch\WirtschaftsId\WirtschaftsId; (new WirtschaftsId('DE123456788-00001')) ->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\WirtschaftsId\Exceptions\InvalidWirtschaftsIdWithoutUnterscheidungsmerkmalLength::class
.
validateWirtschaftsId('DE12345678')->getErrors(); // [ // 'Rechtlogisch\WirtschaftsId\Exceptions\InvalidWirtschaftsIdWithoutUnterscheidungsmerkmalLength' // => 'Wirtschafts-ID must be 11 characters long. Provided Wirtschafts-ID is: 10 characters long.', // ]
or
use Rechtlogisch\WirtschaftsId\WirtschaftsId; (new WirtschaftsId('DE12345678')) ->validate() ->getErrors(); // [ // 'Rechtlogisch\WirtschaftsId\Exceptions\InvalidWirtschaftsIdWithoutUnterscheidungsmerkmalLength' // => 'Wirtschafts-ID must be 11 characters long. Provided Wirtschafts-ID is: 10 characters long.', // ]
Plausibility hints
You can get a list of hints explaining why the provided input is not plausible. Hints do not change the validation result. The validate()
method returns a DTO with a getHints()
method.
Note
The keys of getHints()
hold the stringified reference to the exception class. You can check for a particular error by comparing to the ::class constant. For example: Rechtlogisch\WirtschaftsId\Exceptions\UnterscheidungsmerkmalShouldBe00001BeforeYear2026::class
.
validateWirtschaftsId('DE123456788-00002')->getHints(); // [ // 'Rechtlogisch\WirtschaftsId\Exceptions\UnterscheidungsmerkmalShouldBe00001BeforeYear2026' // => 'Unterscheidungsmerkmal (after -) is typically "00001" before year 2026.', // ]
Tip
You can of course use the alternative way of validation presented in the Usage section.
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.