Detectors
REGON
Detect and validate Polish business registry numbers with weighted Mod 11 checksum for 9-digit and 14-digit variants.
Purpose
Use the regon detector for Polish business registry numbers (REGON - Rejestr Gospodarki Narodowej).
Detector Name
regonSupported Formats
- 9 digits:
NNNNNNNNN - 14 digits:
NNNNNNNNNNNNNN
FastPII validates both formats.
Validation Logic
- Require exactly 9 or 14 digits.
- Run the appropriate weighted Mod 11 checksum.
Checksum Algorithm (9-digit)
- Multiply each digit by weights
[8, 9, 2, 3, 4, 5, 6, 7]. - Sum the products.
- Take
sum % 11. - If the result is
10, the checksum digit is0. Otherwise, the result is the checksum digit. - Compare with the 9th digit.
Checksum Algorithm (14-digit)
- Multiply each digit by weights
[2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8]. - Sum the products.
- Take
sum % 11. - If the result is
10, the checksum digit is0. Otherwise, the result is the checksum digit. - Compare with the 14th 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("REGON: 123456785", detector_names=["regon"])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("123456785", "regon")
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("REGON: 123456785")
for finding in result.findings:
print(finding.type, finding.value)Limitations
- REGON is specific to Polish business registry numbers.
- The 9-digit and 14-digit formats have different checksum algorithms.