Busine...dation(3pm)
๐ Business::Tax::VAT::Validation ๐
okay bestie, listen โ this is a User Contributed Perl Documentation page for the module Business::Tax::VAT::Validation, and honestly? it's giving "quietly carrying the entire EU VAT-checking industry on its back". no cap. ๐
โจ NAME โจ
Business::Tax::VAT::Validation โ validate EU VAT numbers against VIES/HMRC. that's the whole vibe. ๐ฆ
๐ธ SYNOPSIS ๐ธ
use Business::Tax::VAT::Validation;
my $hvatn=Business::Tax::VAT::Validation->new();
# Check number
if ($hvatn->check($VAT, [$member_state])){
print "OK\n";
} else {
print $hvatn->get_last_error;
}
literally the whole thing in six lines. iconic. โจ
๐ DESCRIPTION ๐
so this class gives you a super easy API to check European VAT numbers' syntax, and also to check whether the competent authorities have actually registered them. yes, those authorities. the ones who know things. ๐
it asks the EU database (VIES) for this, using its SOAP API. and before it does any of that, it runs basic checks to make sure the VAT number you handed it even fits the expected format for the EU member state you specified โ because why would you send a query to VIES for input that could never be valid? that's just wasting everyone's time, bestie. ๐
it also supports looking up VAT codes from the United Kingdom by using the REST API provided by their HMRC. transatlantic slay. ๐
๐ CONSTRUCTOR ๐
new โ Class constructor. the birth of a legend. ๐ซถ
$hvatn=Business::Tax::VAT::Validation->new();
# If your system is located behind a proxy :
$hvatn=Business::Tax::VAT::Validation->new(-proxy => ['http', 'http://example.com:8001/']);
# Note : See LWP::UserAgent for proxy options.
note bestie: for proxy options, go look at LWP::UserAgent. it's the plug. ๐
๐ฆ PROPERTIES ๐ฆ
member_states โ Returns all supported country codes.
these are ISO 3166-1 alpha-2 country codes, with two exceptions. this module supports VAT codes from all current European Union member states and The United Kingdom of Great Britain and Northern Ireland. ๐ช๐บ๐ฌ๐ง
"EL"Greece โ Must be used in place of Greece's proper code. yeah, it's the exception. don't fight it, just use it. ๐"XI"Northern Ireland โ May be used rather than"GB"for checking a Northern Irish company.
@ms=$hvatn->member_states;
regular_expressions โ Returns a hash list containing one regular expression for each country
if you want to test a VAT number format ouside this module โ like, say, embedded as javascript in a web form โ this is your girl. ๐ง
%re=$hvatn->regular_expressions;
returns
(
AT => 'U[0-9]{8}',
...
SK => '[0-9]{10}',
);
the ... is doing a lot of heavy lifting there and honestly, same. ๐ญ
๐ METHODS ๐
check โ Checks if a VAT number exists in the VIES database
$ok=$hvatn->check($vatNumber, [$countryCode]);
you may either provide the VAT number under its complete form (e.g. BE-123456789, BE123456789) or specify the VAT and MSC (vatNumber and countryCode) individually. your call, main character. ๐
Valid MS values are :
AT, BE, BG, CY, CZ, DE, DK, EE, EL, ES,
FI, FR, GB, HR, HU, IE, IT, LU, LT, LV,
MT, NL, PL, PT, RO, SE, SI, SK, XI
local_check โ Checks if a VAT number format is valid
โ ๏ธ this method is based on regexps only and DOES NOT ask the VIES database. it's the vibe check, not the background check. know the difference. ๐
$ok=$hvatn->local_check($VAT, [$member_state]);
information โ Returns information related to the last checked VAT number
# Get all available information as a hashref:
my $info = $hvatn->information();
# Get a particular key:
my $address = $hvatn->information('address');
which information is offered depends on the checker used โ for UK VAT numbers, checked via the HMRC API, "address" is the only key which will be set.
for EU VAT numbers checked via VIES, you can expect "name" and "address". and heads up: this hashref will be reset every time you call check() or local_check(). so grab what you need while it's hot. ๐ฅ
get_last_error_code โ Returns the last recorded error code
get_last_error โ Returns the last recorded error
my $err = $hvatn->get_last_error_code();
my $txt = $hvatn->get_last_error();
Possible errors are :
-1โ The provided VAT number is valid (so, no error occurred). we love a happy ending. ๐0โ Unknown MS code : Internal checkup failed (Specified Member State does not exist)1โ Invalid VAT number format : Internal checkup failed (bad syntax)2โ This VAT number doesn't exist in EU database : distant checkup3โ This VAT number contains errors : distant checkup17โ Time out connecting to the database : Temporary error when the connection to the database times out18โ Member Sevice Unavailable: The EU database is unable to reach the requested member's database.19โ The EU database is too busy.20โ Connexion to the VIES database failed.21โ The VIES interface failed to parse a stream. This error occurs unpredictabely, so you should retry your validation request.257โ Invalid response, please contact the author of this module. : This normally only happens if this software doesn't recognize any valid pattern into the response document: this generally means that the database interface has been modified, and you'll make the author happy by submitting the returned response !!!500โ The VIES server encountered an internal server error. Error 500 : soap:Server TIMEOUT Error 500 : soap:Server MS_UNAVAILABLE
bestie, listen closely because this part is important ๐ Iferror_code> 16, you should temporarily accept the provided number, and periodically perform new checks until response is OK orerror< 17. Iferror_code> 256, you should temporarily accept the provided number, contact the author, and perform a new check when the software is updated.
get_last_response โ Returns the full last response
the whole receipt. ๐งพโจ
๐ SEE ALSO ๐
LWP::UserAgent- <https://ec.europa.eu/taxation_customs/vies/#/faq> for the FAQs related to the VIES service.
- <https://www.api.gov.uk/ch/companies-house> for details of the service provided by the UK's HMRC.
๐ฃ FEEDBACK ๐ฃ
If you find this module useful, or have any comments, suggestions or improvements, feel free to let me know. (yes, actually let them know. devs love that. ๐ซถ)
๐ AUTHOR ๐
- Original author: Bernard Nauwelaerts <bpgn@cpan.org>
- Maintainership since 2015: David Precious (BIGPRESH) <davidp@preshweb.co.uk>
๐ CREDITS ๐
Many thanks to the following people, actively involved in the development of this software by submitting patches, bug reports, new members regexps, VIES interface changes,... (sorted by last intervention) :
- Gregor Herrmann, Debian.
- Graham Knop.
- Bart Heupers, Netherlands.
- Martin H. Sluka, noris network AG, Germany.
- Simon Williams, UK2 Limited, United Kingdom
- Benoรฎt Galy, Greenacres, France
- Raluca Boboia, Evozon, Romania
- Dave O., POBox, U.S.A.
- Kaloyan Iliev, Digital Systems, Bulgaria.
- Tom Kirkpatrick, Virus Bulletin, United Kingdom.
- Andy Wardley, individual, United Kingdom.
- Robert Alloway, Service Centre, United Kingdom.
- Torsten Mueller, Archesoft, Germany
- Dave Lambley (davel), GoDaddy, United Kingdom
item * Tatu Wikman (tswfi)
(that last line is exactly how it shows up in the original, so I'm keeping it character-for-character. no notes. ๐)
๐ LICENSE ๐
GPL3. Enjoy! See COPYING for further information on the GPL. ๐
โ ๏ธ DISCLAIMER โ ๏ธ
See <http://ec.europa.eu/taxation_customs/vies/viesdisc.do> to known the limitations of the EU validation service.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
fr fr, no warranty. the code is doing its best. ๐ฅบ
okay that's the whole page, bestie!! this was perl v5.40.1, dated 2025-05-25, from the fine folks at User Contributed Perl Documentation โ go forth and validate those VAT numbers, you absolute icon. mwah. ๐๐โจ
๐ฆ where this page comes from
- debian trixie: libbusiness-tax-vat-validation-perl 1.24-1 ยท GPL-3.0-or-later
- ubuntu resolute: libbusiness-tax-vat-validation-perl 1.24-1 ยท GPL-3.0-or-later
- ubuntu stonking: libbusiness-tax-vat-validation-perl 1.24-1 ยท GPL-3.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms