npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angular-jsvat

v1.1.0

Published

Check the validity of the format of an EU VAT number specified

Downloads

218

Readme

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

NPM

angular-jsvat

Demo and Examples

Check the validity of the format of an EU VAT number. No dependencies.(except angularjs of course).

What is it?

Angular-js wrapper for jsvat (jsvat it's a core-logic for vat validation)

angular-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.

For more details check jsvat repo.

What angular-jsvat do?

  1. Provide JsVatFactory fcatory (just an angularjs wrapper for jsvat)

Just check is VAT number valid or not and which country this VAT is:

JsVatFactory.checkVAT('BG131134023'); // {isValid: true, country: 'bulgaria', value: 'BG131134023'}
JsVatFactory.checkVAT('BG0433170001'); //{isValid: false, country: null, value: 'BG0433170001'}
JsVatFactory.checkVAT('atu5-150-7409');  //{isValid: true, country: 'austria', value: 'ATU51507409'}
JsVatFactory.checkVAT('aTU 5 804 4146');  //{isValid: true, country: 'austria', value: 'ATU58044146'}

You can specify list of allowed countries

JsVatFactory.config = ['austria', 'belgium']; //All countries except 'austria' and 'belgium' would return false
JsVatFactory.checkVAT('BG131134023'); //valid VAT, but result would be 'false'

To reset config just do JsVatFactory.config = [];

  1. Provide jsvat directive (for inputs). Directive take a ngModel and return the result to the result object
<input jsvat="result" type="text" ng-model="model">

Installation

  1. Bower

bower i angular-jsvat --save

  1. NPM (node.js)

npm i angular-jsvat --save

  1. Directly download one of the latest releases:

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

After that, just include angular-jsvat as a dependency

angular.module('app', ['angular-jsvat'])

(no dependencies required, angular-jsvat is standalone app)

How does jsvat check the validity?

It use jsvat core functionality:

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

Browsers Supports

Support all browsers down to IE9 (including IE9).

LICENSE

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