Validates the German VAT-ID (Umsatzsteuer-Identifikationsnummer)

v1.0.0 2024-07-09 14:48 UTC

This package is auto-updated.

Last update: 2024-09-09 15:22:21 UTC


README

Recht logisch USt-ID banner image

Latest Version on Packagist Tests Total Downloads

ust-id

Validates the German VAT-ID (Umsatzsteuer-Identifikationsnummer)

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).

Hint: 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('DE123456789'); // => true

or

use Rechtlogisch\UstId\UstId;

(new UstId('DE123456789'))
    ->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.

Hint: 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.