Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsvat

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsvat

Check the validity of the format of an EU VAT number

  • 1.1.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
52K
increased by2.82%
Maintainers
1
Weekly downloads
 
Created
Source

Codacy Badge bitHound Overall Score bitHound Code Code Climate Build Status Bower version npm version devDependency Status GitHub license

NPM

jsvat

[Demo and Examples]

Check the validity of the format of an EU VAT number. No dependencies.

What is it?

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.

What jsvat do?

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 = [];

Installation

  1. Bower

bower i jsvat --save

  1. NPM (node.js)

npm i jsvat --save

  1. Directly download one of the latest releases:

https://github.com/se-panfilov/jsvat/releases

  1. Just use jsvat.chcekVat(vat, isDetailed) from global scope. If you didn't like global scope - wrap it'

How to use jsvat?

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;

How does jsvat check the validity?

There is 2-step check:

  1. Compare with list of Regexps;

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.

  1. Some magic mathematical counting;

Here we make some mathematical calculation (different for each country). After that we may be sure that ATU99999999and for example ATV66889218 isn't valid, but ATU12011204 is valid.

List of supported Countries:

  • Austria
  • Belgium
  • Bulgaria
  • Switzerland
  • Cyprus
  • Czech Republic
  • Germany
  • Denmark
  • Greece
  • Spain
  • Europe
  • Finland
  • France
  • United Kingdom
  • Croatia
  • Hungary
  • Ireland
  • Italy
  • Latvia
  • Lithunia
  • Luxembourg
  • Malta
  • Netherlands
  • Norway
  • Poland
  • Portugal
  • Romania
  • Russia Federation
  • Serbia
  • Slovenia
  • Slovakia republic
  • Sweden

Versions for frameworks:

Browsers Supports

Support all browsers down to IE9 (including IE9).

Source of inspiration:

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.

Changelog

#####1.1.0

  • jsvat now always return Object (there is no more just true or false value);
  • Changed way of jsvat configuretion (instead of object with countries, now you should pass an array with list of allowed countries);

LICENSE

MIT: https://github.com/se-panfilov/jsvat/blob/master/LICENSE

Keywords

FAQs

Package last updated on 28 Sep 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc