Security News
Research
Supply Chain Attack on Rspack npm Packages Injects Cryptojacking Malware
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Check the validity of the format of an EU VAT number. No dependencies.
jsvat is a small library to check validity of European (and few non-eu) VAT number. (learn more about VAT) jsvat use 2-step check (see below) and didn't make any request for external resources.
Each country has own regexp for VAT number and different math-logic of number calculating.
Just check is VAT number valid or not and which country this VAT is:
jsvat.checkVAT('BG131134023'); // {isValid: true, country: 'bulgaria', value: 'BG131134023'}
jsvat.checkVAT('BG0433170001'); //{isValid: false, country: null, value: 'BG0433170001'}
jsvat.checkVAT('atu5-150-7409'); //{isValid: true, country: 'austria', value: 'ATU51507409'}
jsvat.checkVAT('aTU 5 804 4146'); //{isValid: true, country: 'austria', value: 'ATU58044146'}
You can specify list of allowed countries
jsvat.config = ['austria', 'belgium']; //All countries except 'austria' and 'belgium' would return false
jsvat.checkVAT('BG131134023'); //valid VAT, but result would be 'false'
To reset config just do jsvat.config = [];
bower i jsvat --save
npm i jsvat --save
https://github.com/se-panfilov/jsvat/releases
jsvat.chcekVat(vat, isDetailed)
from global scope.
If you didn't like global scope - wrap it'It's simple:
jsvat.chcekVat(vat); //returns Object
vat
param means VAT number (string
), like "BG0433170001".vat
can be passed with '-' (BG0-4331-70001
) or ' ' (space, like BG 0433 17 0001
) characters;
There is 2-step check:
For example regexp for austria is /^(AT)U(\d{8})$/
.
Looks like ATU99999999
is valid (it's successfied the regexp), but actually it's should be invalid.
Here we make some mathematical calculation (different for each country).
After that we may be sure that ATU99999999
and for example ATV66889218
isn't valid, but ATU12011204
is valid.
Support all browsers down to IE9 (including IE9).
Based on this great work: http://www.braemoor.co.uk/software/vat.shtml
At the moment the code was in public access without any license information.
I'm totally rewrite all the code.
#####1.1.0
MIT: https://github.com/se-panfilov/jsvat/blob/master/LICENSE
FAQs
Check the validity of the format of an EU VAT number
The npm package jsvat receives a total of 50,625 weekly downloads. As such, jsvat popularity was classified as popular.
We found that jsvat demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.
Security News
Sonar’s acquisition of Tidelift highlights a growing industry shift toward sustainable open source funding, addressing maintainer burnout and critical software dependencies.