REGON
REGON (Rejestr Gospodarki Narodowej) is Poland’s business registry identifier. It exists in two forms:
- 9 digits — for individual entities (sole traders, natural persons).
- 14 digits — for legal entities with local units (the first 9 digits are the base REGON, the last 5 identify the local unit).
import { Numerik } from '@slashlab/numerik-js'
// BooleanNumerik.regon().isValid('850518457') // true (9-digit)Numerik.regon().isValid('85051845749370') // true (14-digit)
// Rich resultconst result = Numerik.regon().validate('850518457')result.isValid // true
// Parse to value objectconst regon = Numerik.regon().parse('850518457')
// Null on failure instead of exceptionconst maybe = Numerik.regon().tryParse('bad-input') // nullValue object API
Section titled “Value object API”parse() and tryParse() return a Regon instance.
| Method | Return type | Description |
|---|---|---|
getRaw() | string | The original input, untouched. |
getNormalized() | string | Whitespace-stripped digits. |
toString() | string | Alias for getNormalized(). |
Type & structure
Section titled “Type & structure”| Method | Return type | Description |
|---|---|---|
getType() | RegonType | RegonType.Individual (9-digit) or RegonType.LegalEntity (14-digit). |
getBaseRegon() | string | First 9 digits — always present for both types. |
getLocalUnitSuffix() | string | null | Last 5 digits for 14-digit numbers; null for 9-digit. |
isLocalUnit() | boolean | true for 14-digit (legal entity with local unit). |
Examples
Section titled “Examples”import { Numerik, RegonType } from '@slashlab/numerik-js'
// 9-digit REGONconst regon = Numerik.regon().parse('850518457')
regon.getType() // RegonType.Individualregon.getBaseRegon() // '850518457'regon.getLocalUnitSuffix() // nullregon.isLocalUnit() // false
// 14-digit REGONconst regon14 = Numerik.regon().parse('85051845749370')
regon14.getType() // RegonType.LegalEntityregon14.getBaseRegon() // '850518457'regon14.getLocalUnitSuffix() // '49370'regon14.isLocalUnit() // trueFailure reasons
Section titled “Failure reasons”| Reason | Value | When |
|---|---|---|
InvalidLength | invalid_length | Input is not exactly 9 or 14 digits after normalisation. |
InvalidCharacters | invalid_characters | Non-digit characters remain after stripping whitespace. |
InvalidChecksum | invalid_checksum | Checksum digit does not match. For 14-digit, can refer to either the base 9-digit check or the full 14-digit check. |
Validation algorithm
Section titled “Validation algorithm”9-digit weights: 8, 9, 2, 3, 4, 5, 6, 7
14-digit weights: 2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8
9-digit validation:
- Strip whitespace. Assert exactly 9 digits.
- Multiply the first 8 digits by the 9-digit weights, sum, take
mod 11. If the result is10, the checksum digit must be0. Otherwise the result must equal digit 9.
14-digit validation:
- Strip whitespace. Assert exactly 14 digits.
- Validate the first 9 digits as a standalone 9-digit REGON.
- Multiply all 13 significant digits by the 14-digit weights, sum, take
mod 11. If the result is10, checksum digit must be0. Otherwise the result must equal digit 14.
See Algorithms for the full reference.