The Vat Validation API is a simple API that allows you to validate VAT numbers for a given country code. Or more simply, prevalidate before using the corresponding APIs to actually validate. At the moment countries from the EU are supported as well as Switzerland.
The Vat Validation API is used to run the necessarry validations before a call to the EU or Swiss VAT APIs occurs.
- The API is able to receive a given VAT number and after validations, it strips the country code because this is how the services expect to process it.
- The API is able to determine which external web service to use based on the
countryCode:- If the
countryCodeis supported by the EU service, the service must make a request to the EU web service. EU Web Service - If the
countryCodeis supported by the Switzerland service, the service must make a request to the Switzerland web service. Switzerland Web Service - If the
countryCodeis not supported by either service, the service must return a501 Not Implementederror.
- If the
- Node.js v22.13
- pnpm v10.0.0
- Clone the Repo
git clone git@github.com:vlahunter/ist-coding-challenge.git
cd ist-coding-challenge- Install the dependencies
pnpm install- Run the API
pnpm run start- Example Usage
After the API is up and running use any REST client of your choice to make a POST request to the
/api/vat/validateendpoint. Use the json below as the Request Body.
// for the EU Service
{
"countryCode": "AT",
"vat": "U18522105"
}
// or for the Swiss Service
{
"countryCode": "CH",
"vat": "CHE-116.267.986"
}- Run tests
pnpm run test- Important notes on usage
The API is able to receive a given VAT number and after validations, it strips the country code because this is how the services expect to process it. For example:
// provided by user
{
"countryCode": "AT",
"vat": "ATU18522105"
}
// becomes
{
"countryCode": "AT",
"vat": "U18522105"
}
// more examples, User provides this
{
"countryCode": "NL",
"vat": "NL803441526B01"
}
// becomes like this
{
"countryCode": "NL",
"vat": "803441526B01"
}The API docs are available in the docs folder, in the openapi.yaml file.
To configure the API please edit the config/configuration.json file or navigate to source/models/ConfigurationModel.ts.
- Express: For handling REST requests.
- Zod: For request validation.
- Jest and Supertest: For testing.
Please feel free to contribute to the project. Create a branch and submit a PR.
MIT License.