Structural validation of VAT and tax IDs at checkout
AI Commerce checks tax IDs against country-specific rules and displays errors immediately – fewer corrections, faster invoicing.
Table of Contents
Separate format check from tax ID validity
Structural validation of VAT and tax IDs at the checkout checks the format of the ID based on the selected country. It does not perform a VIES, tax administration or other registry query based on the current code, nor does it prove that the ID is valid or belongs to the customer.
AI Commerce Cloud's extended format validation can give an error right at checkout, but it alone does not guarantee higher quality tax information, fewer error entries, or smoother invoicing. EU, UK, and US identifiers should be evaluated based on actual code coverage, not a general global coverage promise.
The Finnish storefront field is Y-Tunnus , and the error message is Invalid Y-tunnus . However, in international B2B taxation, the same database field may contain an EU VAT number. Determine the tax treatment with a separate approved tax rule, not just based on a regex match.
When does the cashier check the ID?
Structural validation of VAT and tax IDs at checkout goes through the customer and billing sections. Empty company and empty tax ID are accepted. If either is provided, the field lengths are checked. The actual country-specific format validation is done when the legacySettings setting VALIDATE_CLIENT_VAT_ID is enabled.
The database length of the tax ID in the current field rule is 0-14 characters before format validation. The error stops the progress and targets the tax ID field in the customer or billing section. This validator does not by itself make the field mandatory; define B2B/B2C requirements separately.
How to normalize input
Structural validation of VAT and tax codes at checkout converts letters to uppercase and removes spaces and dashes. If the normalized code starts with the two-letter country code of the selected country, the same prefix is removed before the country-specific check.
Therefore, for example, Finnish FI12345678 , 12345678 and 1234567-8 will result in an eight-digit format check. Prefix processing is based on the customer's selected country; a prefix from another country should not be used as a way to bypass the rule.
Country-specific structural rules
Structural validation of VAT and tax IDs at checkout uses the following current code rules after normalization:
| Country | Approved structure | Example |
|---|---|---|
| FI, DK, LU, SI, HU, MT | 8 numbers | FI12345678 |
| DE, EE, EL, PT | 9 numbers | DE123456789 |
| LV, HR, IT | 11 numbers | IT12345678901 |
| SE | 12 digits | SE123456789012 |
| BE, PL, SK | 10 numbers | BE1234567890 |
| LT | 9 or 12 digits | LT123456789012 |
| AT | U and 8 numbers | ATU12345678 |
| BG | 9–10 digits | BG123456789 |
| CY | 8 numbers and a letter | CY12345678X |
| CZ | 8–10 numbers | CZ1234567890 |
| FR | 2 letters/numbers and 9 numbers | FRAB123456789 |
| ES | letter/number, 7 numbers and letter/number | ESX1234567X |
| IE | 7 numbers and 1–2 letters | IE1234567TW |
| NL | 9 numbers, B and 2 numbers | NL123456789B01 |
| GB | GD/HA and 3 digits or 9 digits and optional 3 digits |
GBGD123 , GBHA321 , GB123456789000
|
| RO | 2–10 numbers | RO1234567890 |
The groups currently cover Austria, Belgium, Bulgaria, Cyprus, Czech Republic, Germany, Denmark, Estonia, Greece, Spain, Finland, France, Croatia, Hungary, Ireland, Italy, Lithuania, Luxembourg, Latvia, Malta, Netherlands, Poland, Portugal, Romania, Sweden, Slovenia, Slovakia and the United Kingdom. The country code and the rule for it are read together.
The table describes only the software’s current structural rules. It does not confirm current government regulations, verification numbers, registration, or reverse charge.
Other countries and US EIN
Structural validation of VAT and tax IDs at checkout uses the general rule for other country codes: at least 3 letters or numbers, of which at least 2 are numbers. The minimum limit of 5 characters in the source article does not match the current code.
No specific nine-digit rule was found for the US EIN. The US uses the same general rule, so a too-broad identifier may pass review. Do not publish a claim of EIN validation until a specific rule, tests, and tax owner approval are in place.
Note the Greek GR and EL conflict
The structured validation of VAT and tax codes at checkout classifies Greece as an EU country with the code GR , but in the regex table, the special rule for the nine digits is keyed EL . The prefix is only removed if it matches the selected country code. Thus, GR country selection and EL tax code do not form an unambiguous current path.
Guidance for Greek tax IDs and their use in production remain blocked until country-code normalization is fixed or the intended behavior is confirmed. Do not advise the user to change the country or prefix as a workaround.
Test market countries and storage
Structural validation of VAT and tax IDs at checkout is tested with accepted, invalid, too short and too long IDs for each country of sale. Try with and without the country code, lowercase letters, spaces and dashes, and different customer and billing countries.
Verify error message, checkout progress, and value stored in order. Separately check invoice, ERP export, and possible B2B tax treatment. Normalization is done for verification; the current function alone does not prove in which format the original value is stored.
EU classification and maintenance
Structural validation of VAT and tax IDs at checkout uses a separate EU member list for the country classification store , eu , or other . The code list is commented out as of May 15, 2025 and includes AT, BE, BG, HR, CY, CZ, DK, EE, FI, FR, DE, GR, HU, IE, IT, LV, LT, LU, MT, NL, PL, PT, RO, SK, SI, ES, and SE.
The member list and tax ID regex are maintainable rules, not a permanent legal table. Name an owner, track regulatory changes, and update code, tests, and instructions as a single change. UK/GB and USA are outside the EU list, even if they have their own or general format rules.