Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validate VAT number offline

Tags:

c#

validation

I'm writing a small app with different inputs from a file (like countrycode, vat number etc) and I have to validate that the vat numbers are in the correct format.

I've tried this one: http://www.codeproject.com/KB/webservices/VATchecker.aspx - and it works.. but, and yes, there's always a but :-), I have to check anywhere from 100 - 500 vat numbers and it's just too slow for that. Besides, I'm not sure they appreciate me hammering their site like that.

Does anyone know of an offline vat-validater I can build into my C# program?

like image 314
Thomas Avatar asked Aug 30 '10 09:08

Thomas


1 Answers

In our online shops, I'm doing it similar to the solution in the Code Project article.

Before submitting it to the web services I do a small regular expression sanity check to filter out "syntactially" wrong VAT IDs and therefore reduce the number of SOAP calls I have to perform.

This is an excerpt from the table I'm using to store the regular expressions, maybe this helps you, if you plan something similar:

Code2    VatIDRegex
----------------------------------------------------------
at       ^ATU[A-Z0-9]{8,8}$
be       ^BE[0-9]{9,9}$
cy       ^CY[0-9]{9,9}$
cz       ^CZ[0-9]{8,10}$
de       ^DE[0-9]{9,9}$
dk       ^DK[0-9]{8,8}$
ee       ^EE[0-9]{9,9}$
es       ^ES[A-Z0-9]{1,1}[0-9]{7,7}[A-Z0-9]{1,1}$
fi       ^FI[0-9]{8,8}$
fr       ^FR[A-Z0-9]{2,2}[0-9]{9,9}$
gb       ^GB[0-9]{9,9}$|^GB[0-9]{12,12}$|^GBGD[0-9]{3,3}$
hu       ^HU[0-9]{8,8}$
ie       ^IE[A-Z0-9]{8,8}$
it       ^IT[0-9]{11,11}$
lt       ^LT[0-9]{9,9}$|^LT[0-9]{12,12}$
lu       ^LU[0-9]{8,8}$
lv       ^LV[0-9]{11,11}$
mt       ^MT[0-9]{8,8}$
nl       ^NL[A-Z0-9]{9,9}B[A-Z0-9]{2,2}$
pl       ^PL[0-9]{10,10}$
pt       ^PT[0-9]{9,9}$
se       ^SE[0-9]{12,12}$
si       ^SI[0-9]{8,8}$
sk       ^SK[0-9]{10,10}$
like image 147
Uwe Keim Avatar answered Nov 16 '22 01:11

Uwe Keim