Skip to content

Validates the German Tax-ID (Steuerliche Identifikationsnummer)

License

Notifications You must be signed in to change notification settings

rechtlogisch/steuer-id

Repository files navigation

Recht logisch Steuer-ID banner image

Latest Version on Packagist Tests Total Downloads

steuer-id

Validates the German Tax-ID (Steuerliche Identifikationsnummer)

Based on the official ELSTER documentation (chapter: 2; as of 2024-03-01).

Installation

You can install the package via composer:

composer require rechtlogisch/steuer-id

Usage

isSteuerIdValid('02476291358'); // => true

or

use Rechtlogisch\SteuerId\SteuerId;

(new SteuerId('02 476 291 358'))
    ->validate() // ValidationResult::class
    ->isValid(); // => true

Hint: Whitespaces are being ignored.

Test-Steuer-IDs

Support for test Steuer-IDs (starting with 0) is enabled by default. Test Steuer-IDs are usually invalid in production. It is recommended to disable them with the following environment variable:

STEUERID_PRODUCTION=true

or in PHP:

putenv('STEUERID_PRODUCTION=true');

Validation errors

You can get a list of errors explaining why the provided input is invalid with:

validateSteuerId('x2476291358')->getErrors(); // => ['Only digits allowed.']

or

use Rechtlogisch\SteuerId\SteuerId;

(new SteuerId('x2476291358'))
    ->validate()
    ->getErrors(); // => ['Only digits allowed.']

Hint: validateSteuerId('...') and (new SteuerId('...'))->validate() return a ValidationResult::class object.

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.