KRS
KRS (Krajowy Rejestr Sądowy) is Poland’s national court register number assigned to legal entities. It is a 10-digit sequential registry number.
use SlashLab\Numerik\Numerik;
// BooleanNumerik::krs()->isValid('0000127206'); // true
// Numbers without leading zeros are accepted and normalisedNumerik::krs()->isValid('127206'); // true
// Rich result$result = Numerik::krs()->validate('0000127206');$result->isValid; // true
// Parse to value object$krs = Numerik::krs()->parse('0000127206');
// Null on failure instead of exception$krs = Numerik::krs()->tryParse('bad-input'); // nullValue object API
Section titled “Value object API”parse() and tryParse() return a SlashLab\Numerik\ValueObjects\Krs instance.
| Method | Return type | Description |
|---|---|---|
getRaw() | string | The original input, untouched. |
getNormalized() | string | Raw digits as provided (no extra padding stored). |
__toString() | string | Same as getNormalized(). |
Formatting & metadata
Section titled “Formatting & metadata”| Method | Return type | Description |
|---|---|---|
getFormatted() | string | Zero-padded to 10 digits, e.g. 0000127206. |
getNumericValue() | int | Numeric integer value of the KRS number. |
Examples
Section titled “Examples”$krs = Numerik::krs()->parse('0000127206');
$krs->getRaw(); // '0000127206'$krs->getNormalized(); // '0000127206'$krs->getFormatted(); // '0000127206'$krs->getNumericValue(); // 127206
// Short form — leading zeros are not required on input$krs = Numerik::krs()->parse('127206');
$krs->getRaw(); // '127206'$krs->getNormalized(); // '127206'$krs->getFormatted(); // '0000127206'$krs->getNumericValue(); // 127206Validation algorithm
Section titled “Validation algorithm”KRS is a sequential registry number with no checksum. Validation is structural only:
- Strip spaces. Assert between 1 and 10 digits remain.
- Assert all remaining characters are digits.
- Assert the numeric value is not zero.
A number that passes these checks is structurally valid — it conforms to the KRS format. It may or may not be an actually registered entity.
Failure reasons
Section titled “Failure reasons”| Reason | Value | When |
|---|---|---|
InvalidLength | invalid_length | Input has more than 10 digits after normalisation. |
InvalidCharacters | invalid_characters | Non-digit characters remain after stripping whitespace. |
AllZeros | all_zeros | All digits are zero — numeric value is 0, which is not a valid registry number. |
AllSameDigit | all_same_digit | All 10 digits are identical — strict mode only. |
If this saved you time → ☕ Buy me a coffee