A Python package for validating VAT numbers.
Project description
PyVAT with Checksums
A robust and accurate VAT number validation library for Python.
Why PyVAT with Checksums?
Most VAT validation libraries check if the string starts with the correct country code and has the correct length. That is not enough.
PyVAT with Checksums goes deeper to ensure data integrity:
- 🧮 Real Checksum Validation: We don't just count digits. We implement the official algorithms defined in the European Commission's VIES VAT Validation Routines specifications (Modulus 11, Modulus 97, etc.) to verify the number is genuinely valid.
- 🛡️ Stop Bad Data: Prevent typos and fake numbers from entering your system. A number can look right but be mathematically impossible—we catch that.
- ⚡ Zero External Dependencies: Lightweight and fast, perfect for high-throughput applications.
Features
- ✅ Mathematical Verification: Implements complex checksum algorithms for supported countries.
- 🌐 Multi-Country Support: Validates VAT numbers for all EU countries and many others (UK, Switzerland, Norway, Russia, etc.).
- 🔍 Format Checking: Validates structure, length, and allowed characters (numeric vs alphanumeric).
- 📦 Modern Python: Fully typed and compatible with modern Python versions.
Installation
pip install pyvat-with-checksums
Or using uv:
uv add pyvat-with-checksums
Usage
Import the validator and the countries you want to check against.
from pyvat_with_checksums import check_vat, belgium, austria
# 1. Valid VAT number (Belgium)
result = check_vat('BE0411905847', [belgium])
print(result.is_valid)
# Output: True
print(result.country.name)
# Output: 'Belgium'
# 2. Invalid Checksum (Looks like a valid format, but fails math check)
# This would pass a simple regex check, but fails here!
result = check_vat('BE0411905848', [belgium])
print(result.is_valid)
# Output: False
# 3. Check against multiple countries
result = check_vat('ATU12345678', [belgium, austria])
if result.is_valid:
print(f"Valid VAT for {result.country.name}")
Supported Countries
Supports a wide range of countries, including but not limited to:
- 🇪🇺 European Union: Austria, Belgium, Bulgaria, Croatia, Cyprus, Czech Republic, Denmark, Estonia, Finland, France, Germany, Greece, Hungary, Ireland, Italy, Latvia, Lithuania, Luxembourg, Malta, Netherlands, Poland, Portugal, Romania, Slovakia, Slovenia, Spain, Sweden.
- 🌍 Non-EU: United Kingdom, Switzerland, Norway, Russia, Serbia, Brazil.
Development
To run tests locally:
make test
To run linting checks:
make lint
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyvat_with_checksums-0.1.0.tar.gz.
File metadata
- Download URL: pyvat_with_checksums-0.1.0.tar.gz
- Upload date:
- Size: 38.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
856a5619a1aa8458b8bb34f45973259fe0d7351241b10fc496c8ddb8298a9178
|
|
| MD5 |
72475c492b02e509a3c7d496e1fab2e2
|
|
| BLAKE2b-256 |
170b98656e842fb85ff665e164c3853172ed405621de5e01b04ae8cba08116aa
|
File details
Details for the file pyvat_with_checksums-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyvat_with_checksums-0.1.0-py3-none-any.whl
- Upload date:
- Size: 26.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33691c942af41db2e10e6bc0e28850a4e5e5bcef08eda469ee45d8768165e037
|
|
| MD5 |
812033d0fad18d205b2adcb6b2440359
|
|
| BLAKE2b-256 |
2032aa4f4e0015ae8eda8617835c44ead0885394ac4566e09f1171a48091edde
|