Utility to validate a German tax identification number (steuerliche Identifikationsnummer
, IdNr) for formal correctness. This concerns both the length, the content and check digit (Prüfziffer
).
The checks are done based on the documented, publicly-available rules (see References). The author is not associated to the German government or tax authorities. There is no warranty whatsoever, that the validation outcome is correct.
The tax identification number is an eleven-digit number, the 11th digit being a check digit. According to documentation tax identification number must meet the following criteria:
- no leading zeros allowed
- the 11th digit is a check digit and is calculated from digits 1-10 (see below)
- in the first 10 digits of the identification number, exactly one digit must be duplicated or triplicated
- if there are 3 identical digits in positions 1 to 10, these identical digits must never appear in directly consecutive positions.
This is a Java 11 project, using Apache Maven build utility. After having cloned this repository, perform the following steps to create a usable artifact (Java archive):
mvnw clean install
You'll find the artifact in the target
-folder. The name matches pattern idnr-validator-(version).jar
.
Having integrated the JAR file in your Java application, validating a given IdNr. is done by calling either one of the following methods:
org.dahlen.IdNrValidator.isValidIdNr(String)
this will return true
or false
as a result or
org.dahlen.IdNrValidator.validateIdNr(String)
this will return a Set of validation errors (if any).
The API documentation (Javadoc) can be generated from command-line using
mvnw site:site
This will output the documentation to sub-folder target/site
.