VAT-EU
The Polish EU VAT number (Numer VAT UE) is Poland’s NIP prefixed with the country code PL, used for intra-EU transactions. Validation strips the prefix and applies the standard NIP MOD-11 algorithm.
import { Numerik } from '@slashlab/numerik-js'
// BooleanNumerik.vatEu().isValid('PL5260250274') // true
// Rich resultconst result = Numerik.vatEu().validate('PL5260250274')result.isValid // true
// Parse to value objectconst vatEu = Numerik.vatEu().parse('PL5260250274')
// Null on failure instead of exceptionconst maybe = Numerik.vatEu().tryParse('bad-input') // nullSeparators in the NIP portion are accepted:
Numerik.vatEu().isValid('PL526-025-02-74') // trueValue object API
Section titled “Value object API”parse() and tryParse() return a VatEu instance.
| Method | Return type | Description |
|---|---|---|
getRaw() | string | The original input, untouched. |
getNormalized() | string | PL prefix followed by 10 raw digits. |
toString() | string | Alias for getNormalized(). |
Extracted data
Section titled “Extracted data”| Method | Return type | Description |
|---|---|---|
getCountryCode() | string | Always 'PL'. |
getNip() | string | The 10-digit NIP portion (without prefix). |
getFormatted() | string | PL + canonical NNN-NNN-NN-NN display form. |
Examples
Section titled “Examples”const vatEu = Numerik.vatEu().parse('PL5260250274')
vatEu.getRaw() // 'PL5260250274'vatEu.getNormalized() // 'PL5260250274'vatEu.getCountryCode() // 'PL'vatEu.getNip() // '5260250274'vatEu.getFormatted() // 'PL526-025-02-74'Failure reasons
Section titled “Failure reasons”| Reason | Value | When |
|---|---|---|
InvalidLength | invalid_length | Input does not produce exactly 10 NIP digits after stripping the prefix and separators. |
InvalidCharacters | invalid_characters | Characters other than PL, digits, hyphens, and spaces are present. |
InvalidFormat | invalid_format | Missing PL prefix, or first 3 NIP digits are 000. |
InvalidChecksum | invalid_checksum | NIP checksum digit does not match. |
AllSameDigit | all_same_digit | All 10 NIP digits are identical — strict mode only. |
Validation algorithm
Section titled “Validation algorithm”- Assert the input begins with
PL(case-insensitive). - Strip the
PLprefix, then strip hyphens and spaces from the remaining digits. - Apply the full NIP validation algorithm to the remaining 10 digits.
See Algorithms for the full NIP reference.