I just published a Rust crate for European Union VAT IDs validation. It performs a syntactic validation of a VAT ID, without querying the VIES database: this is what most developers need, actually, because sometimes you can’t find a VAT ID (especially if it was just assigned) in the VIES database.

The check is currently basic, in the sense that it verifies the structure with a state-dependent (because all EU states have different rules for a VAT ID) but does not perform other offline verifications such as the calculation of the CRC code (for states where it is part of the ID). I have plans to improve this. At present time, anyway, all EU VAT IDs in the VIES FAQ page pass the validation, and the crate contains tests for all of those.

Next improvement would be to add the proper online check provided by VIES: this, even thought with some limitations as mentioned above, would allow to properly check if a VAT ID exists. I see two options to achieve this objective:

  • Use the SOAP web service provided by VIES. One problem is that there doesn’t seem to be a generic SOAP client library for Rust at present time, so the implementation would require more effort.
  • Use, programmatically, the VIES web form: this is easy enough but the form is probably meant for human use, and there might even be some legal restriction for a programmatic use of it.

In any case, since the online check would likely bring in some more dependencies, I’m thinking about a separate crate, in the likes of eu-vat-id-vies, so for offline checks (which seem to be more common), the current (simpler) crate would be enough.