Detectors
NIP
Detect and validate Polish tax identification numbers with weighted Mod 11 checksum.
Purpose
Use the nip detector for Polish tax identification numbers (NIP - Numer Identyfikacji Podatkowej).
Detector Name
nipSupported Formats
- 10 digits:
NNNNNNNNNN - With dashes:
NNN-NNN-NN-NN
FastPII strips dashes before validation.
Validation Logic
- Remove dashes and spaces.
- Require exactly 10 digits.
- Run the weighted Mod 11 checksum.
Checksum Algorithm
- Multiply each digit by weights
[6, 5, 7, 2, 3, 4, 5, 6, 7](first 9 digits). - Sum the products.
- Take
sum % 11. - Compare the result with the 10th digit.
Python Examples
from fastpii import FastPII, DEFAULT_PRIORITY
from fastpii.countries.pl import PolishPack
engine = FastPII(priority=DEFAULT_PRIORITY)
engine.register(PolishPack())
result = engine.detect("NIP: 5260250274", detector_names=["nip"])Validate a value directly
from fastpii import FastPII, DEFAULT_PRIORITY
from fastpii.countries.pl import PolishPack
engine = FastPII(priority=DEFAULT_PRIORITY)
engine.register(PolishPack())
result = engine.validate("5260250274", "nip")
print(result.is_valid)Detect in free text
from fastpii import FastPII, DEFAULT_PRIORITY
from fastpii.countries.pl import PolishPack
engine = FastPII(priority=DEFAULT_PRIORITY)
engine.register(PolishPack())
result = engine.detect("NIP: 5260250274")
for finding in result.findings:
print(finding.type, finding.value)Limitations
- NIP is specific to Polish tax identification.
- The detector relies on context words or explicit formatting to avoid false positives on other 10-digit numbers.