VAT-EU
VAT-EU (Numer VAT UE) is the intra-EU VAT identification number used in cross-border transactions within the European Union. For Polish taxpayers it is the two-letter country prefix PL followed by a standard 10-digit NIP. Validation strips the prefix and applies the NIP MOD-11 checksum algorithm.
use SlashLab\Numerik\Numerik;
// BooleanNumerik::vatEu()->isValid('PL5260250274'); // true
// Separators and lowercase prefix are acceptedNumerik::vatEu()->isValid('PL526-025-02-74'); // trueNumerik::vatEu()->isValid('pl5260250274'); // true
// Rich result$result = Numerik::vatEu()->validate('PL5260250274');$result->isValid; // true
// Parse to value object$vatEu = Numerik::vatEu()->parse('PL5260250274');
// Null on failure instead of exception$vatEu = Numerik::vatEu()->tryParse('bad-input'); // nullValue object API
Section titled “Value object API”parse() and tryParse() return a SlashLab\Numerik\ValueObjects\VatEu instance.
| Method | Return type | Description |
|---|---|---|
getRaw() | string | The original input, untouched. |
getNormalized() | string | PL + 10 digits, e.g. PL5260250274. |
__toString() | string | Same as getNormalized(). |
Formatting & metadata
Section titled “Formatting & metadata”| Method | Return type | Description |
|---|---|---|
getCountryCode() | string | Always PL. |
getNip() | string | The 10-digit NIP without the country prefix. |
getFormatted() | string | PL + standard NIP display format, e.g. PL526-025-02-74. |
Examples
Section titled “Examples”$vatEu = Numerik::vatEu()->parse('PL5260250274');
$vatEu->getRaw(); // 'PL5260250274'$vatEu->getNormalized(); // 'PL5260250274'$vatEu->getCountryCode(); // 'PL'$vatEu->getNip(); // '5260250274'$vatEu->getFormatted(); // 'PL526-025-02-74'
// Separators are stripped; PL prefix is uppercased$vatEu = Numerik::vatEu()->parse('pl526-025-02-74');
$vatEu->getRaw(); // 'pl526-025-02-74'$vatEu->getNormalized(); // 'PL5260250274'Validation algorithm
Section titled “Validation algorithm”- Strip spaces and hyphens. Reject inputs over 32 characters.
- Assert the first two characters are
PL(case-insensitive); fail withInvalidFormat. - Strip the prefix. Assert exactly 10 digits remain; fail with
InvalidLength. - Apply the NIP MOD-11 checksum — see the Algorithms reference.
Failure reasons
Section titled “Failure reasons”| Reason | Value | When |
|---|---|---|
InvalidLength | invalid_length | NIP portion is not exactly 10 digits, or raw input exceeds 32 characters. |
InvalidFormat | invalid_format | Input does not start with PL, or NIP tax office code is 000. |
InvalidCharacters | invalid_characters | NIP portion contains non-digit characters. |
InvalidChecksum | invalid_checksum | NIP MOD-11 check digit does not match. |
AllSameDigit | all_same_digit | NIP consists of a single repeated digit — strict mode only. |
If this saved you time → ☕ Buy me a coffee