vat validator
Validate VAT numbers in different countries
Options
Using with form field
(* denotes a required option)
| Name | HTML attribute | Type | Description |
|---|
country * | data-fv-vat___country | String or Function | An ISO-3166 country code |
message | data-fv-vat___message | String | The error message |
The validator supports the following countries:
| Country | Abbreviation VAT system | Country code |
|---|
| Argentina | - | AR |
| Austria | UID | AT |
| Belgium | n° TVA / BTW-nr / Mwst-nr | BE |
| Brazil | CNPJ | BR |
| Bulgaria | ДДС номер | BG |
| Croatia | PDV-ID; OIB | HR |
| Cyprus | ΦΠΑ | CY |
| Czech Republic | DIČ | CZ |
| Denmark | CVR | DK |
| Estonia | KMKR | EE |
| Finland | ALV nro | FI |
| France | n° TVA | FR |
| Germany | USt-IdNr. | DE |
| Greece | ΑΦΜ | GR |
| Hungary | ANUM | HU |
| Iceland | VSK | IS |
| Ireland | VAT no | IE |
| Italy | P.IVA | IT |
| Latvia | PVN | LV |
| Lithuania | PVM kodas | LT |
| Luxembourg | No. TVA | LU |
| Malta | Vat No. | MT |
| Netherlands | Btw-nr. | NL |
| Norway | Orgnr | NO |
| Poland | NIP | PL |
| Portugal | NIF / NIPC | PT |
| Romania | CIF | RO |
| Russia | ИНН | RU |
| Serbia | PIB | RS |
| Slovakia | IČ DPH | SK |
| Slovenia | ID za DDV | SI |
| South Africa | - | ZA |
| Spain | NIF / CIF | ES |
| Sweden | Momsnr. | SE |
| Switzerland | MWST / TVA / IVA | CH |
| United Kingdom | VAT Reg No | GB |
| Venezuela | RIF | VE |
Using the ES6 module
import { vat } from '/vendors/@form-validation/cjs/validator-vat';
const result = vat().validate({
value: ...,
options: {
country: ...,
message: ...,
},
});
Using the npm package
- Install the validator package:
$ npm install @form-validation/validator-vat
import { vat } from '@form-validation/validator-vat';
const result = vat().validate({
value: ...,
options: {
country: ...,
message: ...,
},
});
Basic example
NPM package example
The following snippet shows how to use the vat validator with the npm package:
import { vat } from '@form-validation/validator-vat';
const res1 = vat().validate({
value: 'U13585627',
options: {
country: 'AT',
message: 'The value is not a valid VAT number',
},
});
const res2 = vat().validate({
value: '13585627',
options: {
country: 'DK',
message: 'The value is not a valid VAT number',
},
});
See also
Changelog
- The validator doesn't work properly if the
message property isn't defined
- Add the npm package
- The German VAT numbers don't start with 0
- The Luxembourgian VAT number validator doesn't work with some numbers
- The Bulgarian VAT validator doesn't work for some VAT numbers
- The French VAT validator doesn't work for some VAT numbers
- Support new format of Dutch VAT number
- Fixed an issue that the
country option isn't passed to the placeholder message
- Separate vat validators to vat package to save imports when using with ES6 module
- Support the Argentinian VAT number
- Support the Swiss VAT numbers that end with TVA, IVA, TPV