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 - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

2

bower.json
{
"name": "jsvat",
"version": "1.1.2",
"version": "1.1.3",
"description": "Check the validity of the format of an EU VAT number",

@@ -5,0 +5,0 @@ "main": "./dist/jsvat.js",

@@ -1,2 +0,2 @@

var jsvat=function(){"use strict";function r(r,e){return e.test(r)}function e(r,e,t){var i=e.exec(r),s=i[2];return u[t].calcs(s)}function t(t,i,s){var l=!1;return r(t,i)&&(l=e(t,i,s)),l}function i(r){return r=r||"",r.toString().toUpperCase().replace(/(\s|-|\.)+/g,"")}function s(r,e){return r&&0!==r.length?-1===r.indexOf(e):!1}function l(r,e){for(var i=u[e].rules.regex,l=0;l<i.length;l++){var c=t(r,i[l],e);if(c)return c&&!s(n.config,e)}return!1}var u={},n={config:[],checkVAT:function(r){var e={value:i(r),isValid:!1,country:null};if(!r)return e;for(var t in u)if(u.hasOwnProperty(t)&&(e.isValid=l(e.value,t),e.isValid))return e.country=t,e;return e}};return u.austria={calcs:function(r){for(var e,t=0,i=0;7>i;i++)e=r.charAt(i)*this.rules.multipliers[i],t+=e>9?Math.floor(e/10)+e%10:e;return t=10-(t+4)%10,10===t&&(t=0),t===+r.slice(7,8)},rules:{multipliers:[1,2,1,2,1,2,1],regex:[/^(AT)U(\d{8})$/]}},u.belgium={calcs:function(r){if(9===r.length&&(r="0"+r),0===+r.slice(1,2))return!1;var e=97-+r.slice(0,8)%97;return e===+r.slice(8,10)},rules:{regex:[/^(BE)(0?\d{9})$/]}},u.bulgaria=function(){function r(r,e,t,i,s){for(var l=t;i>l;l++)r+=+e.charAt(l)*(l+s);return r}function e(r,e,t,i,s){for(var l=t;i>l;l++)r+=+e.charAt(l)*s[l];return r}function t(e){var t,i=0,s=+e.slice(8);return i=r(i,e,0,8,1),t=i%11,10!==t?t===s:(i=r(0,e,0,8,3),t=i%11,10===t&&(t=0),t===s)}function i(r,t){if(/^\d\d[0-5]\d[0-3]\d\d{4}$/.test(r)){var i=+r.slice(2,4);if(i>0&&13>i||i>20&&33>i||i>40&&53>i){var s=e(0,r,0,9,t.multipliers.physical);if(s%=11,10===s&&(s=0),s===+r.substr(9,1))return!0}}return!1}function s(r,t){var i=e(0,r,0,9,t.multipliers.foreigner);return i%10===+r.substr(9,1)?!0:void 0}function l(r,t){var i=e(0,r,0,9,t.multipliers.miscellaneous);if(i=11-i%11,10===i)return!1;11===i&&(i=0);var s=+r.substr(9,1);return i===s}return{calcs:function(r){return 9===r.length?t(r):i(r,this.rules)||s(r,this.rules)||l(r,this.rules)},rules:{multipliers:{physical:[2,4,8,5,10,9,7,3,6],foreigner:[21,19,17,13,11,9,7,3,1],miscellaneous:[4,3,2,7,6,5,4,3,2]},regex:[/^(BG)(\d{9,10})$/]}}}(),u.croatia={calcs:function(r){for(var e,t=10,i=0,s=0;10>s;s++)i=(+r.charAt(s)+t)%10,0===i&&(i=10),t=2*i%11;return e=+r.slice(10,11),(t+e)%10===1},rules:{regex:[/^(HR)(\d{11})$/]}},u.cyprus={calcs:function(r){var e,t=0;if(12===+r.slice(0,2))return!1;for(var i=0;8>i;i++){var s=+r.charAt(i);if(i%2===0)switch(s){case 0:s=1;break;case 1:s=0;break;case 2:s=5;break;case 3:s=7;break;case 4:s=9;break;default:s=2*s+3}t+=s}return t%=26,t=String.fromCharCode(t+65),e=r.substr(8,1),t===e},rules:{regex:[/^(CY)([0-59]\d{7}[A-Z])$/]}},u.czech_republic=function(){function r(r,e){var t=0;if(e.additional[0].test(r)){for(var i=0;7>i;i++)t+=+r.charAt(i)*e.multipliers[i];t=11-t%11,10===t&&(t=0),11===t&&(t=1);var s=+r.slice(7,8);return t===s}return!1}function e(r,e){var t=0;if(e.additional[2].test(r)){for(var i=0;7>i;i++)t+=+r.charAt(i+1)*e.multipliers[i];t=11-t%11,10===t&&(t=0),11===t&&(t=1);var s=+r.slice(8,9);return e.lookup[t-1]===s}return!1}function t(r,e){if(e.additional[3].test(r)){var t=+r.slice(0,2)+r.slice(2,4)+r.slice(4,6)+r.slice(6,8)+r.slice(8),i=+r%11===0;return!(t%11!==0||!i)}return!1}return{calcs:function(i){return r(i,this.rules)?!0:e(i,this.rules)?!0:!!t(i,this.rules)},rules:{multipliers:[8,7,6,5,4,3,2],lookup:[8,7,6,5,4,3,2,1,0,9,10],regex:[/^(CZ)(\d{8,10})(\d{3})?$/],additional:[/^\d{8}$/,/^[0-5][0-9][0|1|5|6]\d[0-3]\d\d{3}$/,/^6\d{8}$/,/^\d{2}[0-3|5-8]\d[0-3]\d\d{4}$/]}}}(),u.denmark={calcs:function(r){for(var e=0,t=0;8>t;t++)e+=+r.charAt(t)*this.rules.multipliers[t];return e%11===0},rules:{multipliers:[2,7,6,5,4,3,2,1],regex:[/^(DK)(\d{8})$/]}},u.estonia={calcs:function(r){for(var e,t=0,i=0;8>i;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return t=10-t%10,10===t&&(t=0),e=+r.slice(8,9),t===e},rules:{multipliers:[3,7,1,3,7,1,3,7],regex:[/^(EE)(10\d{7})$/]}},u.europe={calcs:function(){return!0},rules:{regex:[/^(EU)(\d{9})$/]}},u.finland={calcs:function(r){for(var e,t=0,i=0;7>i;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return t=11-t%11,t>9&&(t=0),e=+r.slice(7,8),t===e},rules:{multipliers:[7,9,10,5,8,4,2],regex:[/^(FI)(\d{8})$/]}},u.france={calcs:function(r){var e,t;return/^\d{11}$/.test(r)?(e=+r.substring(2),e=(100*e+12)%97,t=+r.slice(0,2),e===t):!0},rules:{regex:[/^(FR)(\d{11})$/,/^(FR)([A-HJ-NP-Z]\d{10})$/,/^(FR)(\d[A-HJ-NP-Z]\d{9})$/,/^(FR)([A-HJ-NP-Z]{2}\d{9})$/]}},u.germany={calcs:function(r){for(var e,t=10,i=0,s=0,l=0;8>l;l++)i=(+r.charAt(l)+t)%10,0===i&&(i=10),t=2*i%11;return s=11-t===10?0:11-t,e=+r.slice(8,9),s===e},rules:{regex:[/^(DE)([1-9]\d{8})$/]}},u.greece={calcs:function(r){var e,t=0;8===r.length&&(r="0"+r);for(var i=0;8>i;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return t%=11,t>9&&(t=0),e=+r.slice(8,9),t===e},rules:{multipliers:[256,128,64,32,16,8,4,2],regex:[/^(EL)(\d{9})$/]}},u.hungary={calcs:function(r){for(var e,t=0,i=0;7>i;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return t=10-t%10,10===t&&(t=0),e=+r.slice(7,8),t===e},rules:{multipliers:[9,7,3,1,9,7,3],regex:[/^(HU)(\d{8})$/]}},u.ireland={calcs:function(r){var e,t=0;this.rules.typeFormats.first.test(r)&&(r="0"+r.substring(2,7)+r.substring(0,1)+r.substring(7,8));for(var i=0;7>i;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return this.rules.typeFormats.third.test(r)&&(t+="H"===r.charAt(8)?72:9),t%=23,t=0===t?"W":String.fromCharCode(t+64),e=r.slice(7,8),t===e},rules:{multipliers:[8,7,6,5,4,3,2],typeFormats:{first:/^\d[A-Z\*\+]/,third:/^\d{7}[A-Z][AH]$/},regex:[/^(IE)(\d{7}[A-W])$/,/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/,/^(IE)(\d{7}[A-W][AH])$/]}},u.italy={calcs:function(r){var e,t,i=0;if(0===+r.slice(0,7))return!1;if(e=+r.slice(7,10),1>e||e>201&&999!==e&&888!==e)return!1;for(var s=0;10>s;s++)e=+r.charAt(s)*this.rules.multipliers[s],i+=e>9?Math.floor(e/10)+e%10:e;return i=10-i%10,i>9&&(i=0),t=+r.slice(10,11),i===t},rules:{multipliers:[1,2,1,2,1,2,1,2,1,2],regex:[/^(IT)(\d{11})$/]}},u.latvia={calcs:function(r){var e,t=0;if(/^[0-3]/.test(r))return!!/^[0-3][0-9][0-1][0-9]/.test(r);for(var i=0;10>i;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return t%11===4&&9===r[0]&&(t-=45),t%11===4?t=4-t%11:t%11>4?t=14-t%11:4>t%11&&(t=3-t%11),e=+r.slice(10,11),t===e},rules:{multipliers:[9,1,4,8,3,10,2,5,7,6],regex:[/^(LV)(\d{11})$/]}},u.lithunia=function(){function r(r,e,t){return+r.charAt(t)*e[t]}function e(e,t,i){if(t%11===10){t=0;for(var s=0;8>s;s++)t+=r(e,i.multipliers["short"],s)}return t}function t(r,e){for(var t=0;8>t;t++)e+=+r.charAt(t)*(t+1);return e}function i(r){return r%=11,10===r&&(r=0),r}function s(r,s){var l=0;if(9===r.length){if(!/^\d{7}1/.test(r))return!1;l=t(r,l),l=e(r,l,s),l=i(l);var u=+r.slice(8,9);return l===u}return!1}function l(e,t,i){for(var s=0;11>s;s++)t+=r(e,i.multipliers.med,s);return t}function u(e,t,i){if(t%11===10){t=0;for(var s=0;11>s;s++)t+=r(e,i.multipliers.alt,s)}return t}function n(r,e){var t=0;if(12===r.length){if(!e.check.test(r))return!1;t=l(r,t,e),t=u(r,t,e),t=i(t);var s=+r.slice(11,12);return t===s}return!1}return{calcs:function(r){return s(r,this.rules)||n(r,this.rules)},rules:{multipliers:{"short":[3,4,5,6,7,8,9,1],med:[1,2,3,4,5,6,7,8,9,1,2],alt:[3,4,5,6,7,8,9,1,2,3,4]},check:/^\d{10}1/,regex:[/^(LT)(\d{9}|\d{12})$/]}}}(),u.luxembourg={calcs:function(r){var e=+r.slice(6,8),t=+r.slice(0,6)%89;return t===e},rules:{regex:[/^(LU)(\d{8})$/]}},u.malta={calcs:function(r){for(var e,t=0,i=0;6>i;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return t=37-t%37,e=+r.slice(6,8),t===e},rules:{multipliers:[3,4,6,7,8,9],regex:[/^(MT)([1-9]\d{7})$/]}},u.netherlands={calcs:function(r){for(var e,t=0,i=0;8>i;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return t%=11,t>9&&(t=0),e=+r.slice(8,9),t===e},rules:{multipliers:[9,8,7,6,5,4,3,2],regex:[/^(NL)(\d{9})B\d{2}$/]}},u.norway={calcs:function(r){for(var e,t=0,i=0;8>i;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return t=11-t%11,11===t&&(t=0),10>t?(e=+r.slice(8,9),t===e):void 0},rules:{multipliers:[3,2,7,6,5,4,3,2],regex:[/^(NO)(\d{9})$/]}},u.poland={calcs:function(r){for(var e,t=0,i=0;9>i;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return t%=11,t>9&&(t=0),e=+r.slice(9,10),t===e},rules:{multipliers:[6,5,7,2,3,4,5,6,7],regex:[/^(PL)(\d{10})$/]}},u.portugal={calcs:function(r){for(var e,t=0,i=0;8>i;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return t=11-t%11,t>9&&(t=0),e=+r.slice(8,9),t===e},rules:{multipliers:[9,8,7,6,5,4,3,2],regex:[/^(PT)(\d{9})$/]}},u.romania={calcs:function(r){for(var e,t=0,i=r.length,s=this.rules.multipliers.slice(10-i),l=0;l<r.length-1;l++)t+=+r.charAt(l)*s[l];return t=10*t%11,10===t&&(t=0),e=+r.slice(r.length-1,r.length),t===e},rules:{multipliers:[7,5,3,2,1,7,5,3,2],regex:[/^(RO)([1-9]\d{1,9})$/]}},u.russia=function(){function r(r,e){var t=0;if(10===r.length){for(var i=0;10>i;i++)t+=+r.charAt(i)*e.multipliers.m_1[i];t%=11,t>9&&(t%=10);var s=+r.slice(9,10);return t===s}return!1}function e(r,e){var t=0,i=0;if(12===r.length){for(var s=0;11>s;s++)t+=+r.charAt(s)*e.multipliers.m_2[s];t%=11,t>9&&(t%=10);for(var l=0;11>l;l++)i+=+r.charAt(l)*e.multipliers.m_3[l];i%=11,i>9&&(i%=10);var u=t===+r.slice(10,11),n=i===+r.slice(11,12);return u&&n}return!1}return{calcs:function(t){return r(t,this.rules)||e(t,this.rules)},rules:{multipliers:{m_1:[2,4,10,3,5,9,4,6,8,0],m_2:[7,2,4,10,3,5,9,4,6,8,0],m_3:[3,7,2,4,10,3,5,9,4,6,8,0]},regex:[/^(RU)(\d{10}|\d{12})$/]}}}(),u.serbia={calcs:function(r){for(var e,t=10,i=0,s=0;8>s;s++)i=(+r.charAt(s)+t)%10,0===i&&(i=10),t=2*i%11;var l=1;return e=(t+ +r.slice(8,9))%10,e===l},rules:{regex:[/^(RS)(\d{9})$/]}},u.slovakia_republic={calcs:function(r){var e=0,t=r%11;return t===e},rules:{regex:[/^(SK)([1-9]\d[2346-9]\d{7})$/]}},u.slovenia={calcs:function(r){for(var e,t=0,i=0;7>i;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return t=11-t%11,10===t&&(t=0),e=+r.slice(7,8),!(11===t||t!==e)},rules:{multipliers:[8,7,6,5,4,3,2],regex:[/^(SI)([1-9]\d{7})$/]}},u.spain={calcs:function(r){var e,t,i=0,s=0;if(this.rules.additional[0].test(r)){for(i=0;7>i;i++)e=r.charAt(i+1)*this.rules.multipliers[i],s+=e>9?Math.floor(e/10)+e%10:e;return s=10-s%10,10===s&&(s=0),t=+r.slice(8,9),s===t}if(this.rules.additional[1].test(r)){for(i=0;7>i;i++)e=r.charAt(i+1)*this.rules.multipliers[i],s+=e>9?Math.floor(e/10)+e%10:e;return s=10-s%10,s=String.fromCharCode(s+64),t=r.slice(8,9),s===t}if(this.rules.additional[2].test(r)){var l=r;return"Y"===l.substring(0,1)&&(l=l.replace(/Y/,"1")),"Z"===l.substring(0,1)&&(l=l.replace(/Z/,"2")),t="TRWAGMYFPDXBNJZSQVHLCKE".charAt(+l.substring(0,8)%23),l.charAt(8)===t}return this.rules.additional[3].test(r)?(t="TRWAGMYFPDXBNJZSQVHLCKE".charAt(+r.substring(1,8)%23),r.charAt(8)===t):!1},rules:{multipliers:[2,1,2,1,2,1,2],regex:[/^(ES)([A-Z]\d{8})$/,/^(ES)([A-HN-SW]\d{7}[A-J])$/,/^(ES)([0-9YZ]\d{7}[A-Z])$/,/^(ES)([KLMX]\d{7}[A-Z])$/],additional:[/^[A-H|J|U|V]\d{8}$/,/^[A-H|N-S|W]\d{7}[A-J]$/,/^[0-9|Y|Z]\d{7}[A-Z]$/,/^[K|L|M|X]\d{7}[A-Z]$/]}},u.sweden={calcs:function(r){for(var e,t,i=0,s=0;9>s;s+=2)t=+r.charAt(s),i+=Math.floor(t/5)+2*t%10;for(var l=0,u=1;9>u;u+=2)l+=+r.charAt(u);var n=(10-(i+l)%10)%10;return e=+r.slice(9,10),n===e},rules:{regex:[/^(SE)(\d{10}01)$/]}},u.switzerland={calcs:function(r){for(var e=0,t=0;8>t;t++)e+=+r.charAt(t)*this.rules.multipliers[t];if(e=11-e%11,10===e)return!1;11===e&&(e=0);var i=+r.substr(8,1);return e===i},rules:{multipliers:[5,4,3,2,7,6,5,4],regex:[/^(CHE)(\d{9})(MWST)?$/]}},u.united_kingdom={calcs:function(r){var e,t=0;if("GD"===r.substr(0,2))return e=500,r.substr(2,3)<e;if("HA"===r.substr(0,2))return e=499,r.substr(2,3)>e;if(0===+r.slice(0))return!1;for(var i=+r.slice(0,7),s=0;7>s;s++)t+=+r.charAt(s)*this.rules.multipliers[s];for(var l=t;l>0;)l-=97;return l=Math.abs(l),l===+r.slice(7,9)&&9990001>i&&(1e5>i||i>999999)&&(9490001>i||i>97e5)?!0:(l>=55?l-=55:l+=42,e=+r.slice(7,9),!!(l===e&&i>1e6))},rules:{multipliers:[8,7,6,5,4,3,2],regex:[/^(GB)?(\d{9})$/,/^(GB)?(\d{12})$/,/^(GB)?(GD\d{3})$/,/^(GB)?(HA\d{3})$/]}},"object"==typeof module&&module.exports&&(module.exports=n),n}();
var jsvat=function(){"use strict";function r(r,e){return e.test(r)}function e(r,e,t){var i=e.exec(r),s=i[2];return u[t].calcs(s)}function t(t,i,s){var l=!1;return r(t,i)&&(l=e(t,i,s)),l}function i(r){return r=r||"",r.toString().toUpperCase().replace(/(\s|-|\.)+/g,"")}function s(r,e){return!(!r||0===r.length)&&r.indexOf(e)===-1}function l(r,e){for(var i=u[e].rules.regex,l=0;l<i.length;l++){var c=t(r,i[l],e);if(c)return c&&!s(n.config,e)}return!1}var u={},n={config:[],checkVAT:function(r){var e={value:i(r),isValid:!1,country:null};if(!r)return e;for(var t in u)if(u.hasOwnProperty(t)&&(e.isValid=l(e.value,t),e.isValid))return e.country=t,e;return e}};return u.austria={calcs:function(r){for(var e,t=0,i=0;i<7;i++)e=r.charAt(i)*this.rules.multipliers[i],t+=e>9?Math.floor(e/10)+e%10:e;return t=10-(t+4)%10,10===t&&(t=0),t===+r.slice(7,8)},rules:{multipliers:[1,2,1,2,1,2,1],regex:[/^(AT)U(\d{8})$/]}},u.belgium={calcs:function(r){if(9===r.length&&(r="0"+r),0===+r.slice(1,2))return!1;var e=97-+r.slice(0,8)%97;return e===+r.slice(8,10)},rules:{regex:[/^(BE)(0?\d{9})$/]}},u.bulgaria=function(){function r(r,e,t,i,s){for(var l=t;l<i;l++)r+=+e.charAt(l)*(l+s);return r}function e(r,e,t,i,s){for(var l=t;l<i;l++)r+=+e.charAt(l)*s[l];return r}function t(e){var t,i=0,s=+e.slice(8);return i=r(i,e,0,8,1),t=i%11,10!==t?t===s:(i=r(0,e,0,8,3),t=i%11,10===t&&(t=0),t===s)}function i(r,t){if(/^\d\d[0-5]\d[0-3]\d\d{4}$/.test(r)){var i=+r.slice(2,4);if(i>0&&i<13||i>20&&i<33||i>40&&i<53){var s=e(0,r,0,9,t.multipliers.physical);if(s%=11,10===s&&(s=0),s===+r.substr(9,1))return!0}}return!1}function s(r,t){var i=e(0,r,0,9,t.multipliers.foreigner);if(i%10===+r.substr(9,1))return!0}function l(r,t){var i=e(0,r,0,9,t.multipliers.miscellaneous);if(i=11-i%11,10===i)return!1;11===i&&(i=0);var s=+r.substr(9,1);return i===s}return{calcs:function(r){return 9===r.length?t(r):i(r,this.rules)||s(r,this.rules)||l(r,this.rules)},rules:{multipliers:{physical:[2,4,8,5,10,9,7,3,6],foreigner:[21,19,17,13,11,9,7,3,1],miscellaneous:[4,3,2,7,6,5,4,3,2]},regex:[/^(BG)(\d{9,10})$/]}}}(),u.croatia={calcs:function(r){for(var e,t=10,i=0,s=0;s<10;s++)i=(+r.charAt(s)+t)%10,0===i&&(i=10),t=2*i%11;return e=+r.slice(10,11),(t+e)%10===1},rules:{regex:[/^(HR)(\d{11})$/]}},u.cyprus={calcs:function(r){var e,t=0;if(12===+r.slice(0,2))return!1;for(var i=0;i<8;i++){var s=+r.charAt(i);if(i%2===0)switch(s){case 0:s=1;break;case 1:s=0;break;case 2:s=5;break;case 3:s=7;break;case 4:s=9;break;default:s=2*s+3}t+=s}return t%=26,t=String.fromCharCode(t+65),e=r.substr(8,1),t===e},rules:{regex:[/^(CY)([0-59]\d{7}[A-Z])$/]}},u.czech_republic=function(){function r(r,e){var t=0;if(e.additional[0].test(r)){for(var i=0;i<7;i++)t+=+r.charAt(i)*e.multipliers[i];t=11-t%11,10===t&&(t=0),11===t&&(t=1);var s=+r.slice(7,8);return t===s}return!1}function e(r,e){var t=0;if(e.additional[2].test(r)){for(var i=0;i<7;i++)t+=+r.charAt(i+1)*e.multipliers[i];t=11-t%11,10===t&&(t=0),11===t&&(t=1);var s=+r.slice(8,9);return e.lookup[t-1]===s}return!1}function t(r,e){if(e.additional[3].test(r)){var t=+r.slice(0,2)+r.slice(2,4)+r.slice(4,6)+r.slice(6,8)+r.slice(8),i=+r%11===0;return!(t%11!==0||!i)}return!1}return{calcs:function(i){return!!r(i,this.rules)||(!!e(i,this.rules)||!!t(i,this.rules))},rules:{multipliers:[8,7,6,5,4,3,2],lookup:[8,7,6,5,4,3,2,1,0,9,10],regex:[/^(CZ)(\d{8,10})(\d{3})?$/],additional:[/^\d{8}$/,/^[0-5][0-9][0|1|5|6]\d[0-3]\d\d{3}$/,/^6\d{8}$/,/^\d{2}[0-3|5-8]\d[0-3]\d\d{4}$/]}}}(),u.denmark={calcs:function(r){for(var e=0,t=0;t<8;t++)e+=+r.charAt(t)*this.rules.multipliers[t];return e%11===0},rules:{multipliers:[2,7,6,5,4,3,2,1],regex:[/^(DK)(\d{8})$/]}},u.estonia={calcs:function(r){for(var e,t=0,i=0;i<8;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return t=10-t%10,10===t&&(t=0),e=+r.slice(8,9),t===e},rules:{multipliers:[3,7,1,3,7,1,3,7],regex:[/^(EE)(10\d{7})$/]}},u.europe={calcs:function(){return!0},rules:{regex:[/^(EU)(\d{9})$/]}},u.finland={calcs:function(r){for(var e,t=0,i=0;i<7;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return t=11-t%11,t>9&&(t=0),e=+r.slice(7,8),t===e},rules:{multipliers:[7,9,10,5,8,4,2],regex:[/^(FI)(\d{8})$/]}},u.france={calcs:function(r){var e,t;return!/^\d{11}$/.test(r)||(e=+r.substring(2),e=(100*e+12)%97,t=+r.slice(0,2),e===t)},rules:{regex:[/^(FR)(\d{11})$/,/^(FR)([A-HJ-NP-Z]\d{10})$/,/^(FR)(\d[A-HJ-NP-Z]\d{9})$/,/^(FR)([A-HJ-NP-Z]{2}\d{9})$/]}},u.germany={calcs:function(r){for(var e,t=10,i=0,s=0,l=0;l<8;l++)i=(+r.charAt(l)+t)%10,0===i&&(i=10),t=2*i%11;return s=11-t===10?0:11-t,e=+r.slice(8,9),s===e},rules:{regex:[/^(DE)([1-9]\d{8})$/]}},u.greece={calcs:function(r){var e,t=0;8===r.length&&(r="0"+r);for(var i=0;i<8;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return t%=11,t>9&&(t=0),e=+r.slice(8,9),t===e},rules:{multipliers:[256,128,64,32,16,8,4,2],regex:[/^(EL)(\d{9})$/]}},u.hungary={calcs:function(r){for(var e,t=0,i=0;i<7;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return t=10-t%10,10===t&&(t=0),e=+r.slice(7,8),t===e},rules:{multipliers:[9,7,3,1,9,7,3],regex:[/^(HU)(\d{8})$/]}},u.ireland={calcs:function(r){var e,t=0;this.rules.typeFormats.first.test(r)&&(r="0"+r.substring(2,7)+r.substring(0,1)+r.substring(7,8));for(var i=0;i<7;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return this.rules.typeFormats.third.test(r)&&(t+="H"===r.charAt(8)?72:9),t%=23,t=0===t?"W":String.fromCharCode(t+64),e=r.slice(7,8),t===e},rules:{multipliers:[8,7,6,5,4,3,2],typeFormats:{first:/^\d[A-Z\*\+]/,third:/^\d{7}[A-Z][AH]$/},regex:[/^(IE)(\d{7}[A-W])$/,/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/,/^(IE)(\d{7}[A-W][AH])$/]}},u.italy={calcs:function(r){var e,t,i=0;if(0===+r.slice(0,7))return!1;if(e=+r.slice(7,10),e<1||e>201&&999!==e&&888!==e)return!1;for(var s=0;s<10;s++)e=+r.charAt(s)*this.rules.multipliers[s],i+=e>9?Math.floor(e/10)+e%10:e;return i=10-i%10,i>9&&(i=0),t=+r.slice(10,11),i===t},rules:{multipliers:[1,2,1,2,1,2,1,2,1,2],regex:[/^(IT)(\d{11})$/]}},u.latvia={calcs:function(r){var e,t=0;if(/^[0-3]/.test(r))return!!/^[0-3][0-9][0-1][0-9]/.test(r);for(var i=0;i<10;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return t%11===4&&9===r[0]&&(t-=45),t%11===4?t=4-t%11:t%11>4?t=14-t%11:t%11<4&&(t=3-t%11),e=+r.slice(10,11),t===e},rules:{multipliers:[9,1,4,8,3,10,2,5,7,6],regex:[/^(LV)(\d{11})$/]}},u.lithunia=function(){function r(r,e,t){return+r.charAt(t)*e[t]}function e(e,t,i){if(t%11===10){t=0;for(var s=0;s<8;s++)t+=r(e,i.multipliers.short,s)}return t}function t(r,e){for(var t=0;t<8;t++)e+=+r.charAt(t)*(t+1);return e}function i(r){return r%=11,10===r&&(r=0),r}function s(r,s){var l=0;if(9===r.length){if(!/^\d{7}1/.test(r))return!1;l=t(r,l),l=e(r,l,s),l=i(l);var u=+r.slice(8,9);return l===u}return!1}function l(e,t,i){for(var s=0;s<11;s++)t+=r(e,i.multipliers.med,s);return t}function u(e,t,i){if(t%11===10){t=0;for(var s=0;s<11;s++)t+=r(e,i.multipliers.alt,s)}return t}function n(r,e){var t=0;if(12===r.length){if(!e.check.test(r))return!1;t=l(r,t,e),t=u(r,t,e),t=i(t);var s=+r.slice(11,12);return t===s}return!1}return{calcs:function(r){return s(r,this.rules)||n(r,this.rules)},rules:{multipliers:{short:[3,4,5,6,7,8,9,1],med:[1,2,3,4,5,6,7,8,9,1,2],alt:[3,4,5,6,7,8,9,1,2,3,4]},check:/^\d{10}1/,regex:[/^(LT)(\d{9}|\d{12})$/]}}}(),u.luxembourg={calcs:function(r){var e=+r.slice(6,8),t=+r.slice(0,6)%89;return t===e},rules:{regex:[/^(LU)(\d{8})$/]}},u.malta={calcs:function(r){for(var e,t=0,i=0;i<6;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return t=37-t%37,e=+r.slice(6,8),t===e},rules:{multipliers:[3,4,6,7,8,9],regex:[/^(MT)([1-9]\d{7})$/]}},u.netherlands={calcs:function(r){for(var e,t=0,i=0;i<8;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return t%=11,t>9&&(t=0),e=+r.slice(8,9),t===e},rules:{multipliers:[9,8,7,6,5,4,3,2],regex:[/^(NL)(\d{9})B\d{2}$/]}},u.norway={calcs:function(r){for(var e,t=0,i=0;i<8;i++)t+=+r.charAt(i)*this.rules.multipliers[i];if(t=11-t%11,11===t&&(t=0),t<10)return e=+r.slice(8,9),t===e},rules:{multipliers:[3,2,7,6,5,4,3,2],regex:[/^(NO)(\d{9})$/]}},u.poland={calcs:function(r){for(var e,t=0,i=0;i<9;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return t%=11,t>9&&(t=0),e=+r.slice(9,10),t===e},rules:{multipliers:[6,5,7,2,3,4,5,6,7],regex:[/^(PL)(\d{10})$/]}},u.portugal={calcs:function(r){for(var e,t=0,i=0;i<8;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return t=11-t%11,t>9&&(t=0),e=+r.slice(8,9),t===e},rules:{multipliers:[9,8,7,6,5,4,3,2],regex:[/^(PT)(\d{9})$/]}},u.romania={calcs:function(r){for(var e,t=0,i=r.length,s=this.rules.multipliers.slice(10-i),l=0;l<r.length-1;l++)t+=+r.charAt(l)*s[l];return t=10*t%11,10===t&&(t=0),e=+r.slice(r.length-1,r.length),t===e},rules:{multipliers:[7,5,3,2,1,7,5,3,2],regex:[/^(RO)([1-9]\d{1,9})$/]}},u.russia=function(){function r(r,e){var t=0;if(10===r.length){for(var i=0;i<10;i++)t+=+r.charAt(i)*e.multipliers.m_1[i];t%=11,t>9&&(t%=10);var s=+r.slice(9,10);return t===s}return!1}function e(r,e){var t=0,i=0;if(12===r.length){for(var s=0;s<11;s++)t+=+r.charAt(s)*e.multipliers.m_2[s];t%=11,t>9&&(t%=10);for(var l=0;l<11;l++)i+=+r.charAt(l)*e.multipliers.m_3[l];i%=11,i>9&&(i%=10);var u=t===+r.slice(10,11),n=i===+r.slice(11,12);return u&&n}return!1}return{calcs:function(t){return r(t,this.rules)||e(t,this.rules)},rules:{multipliers:{m_1:[2,4,10,3,5,9,4,6,8,0],m_2:[7,2,4,10,3,5,9,4,6,8,0],m_3:[3,7,2,4,10,3,5,9,4,6,8,0]},regex:[/^(RU)(\d{10}|\d{12})$/]}}}(),u.serbia={calcs:function(r){for(var e,t=10,i=0,s=0;s<8;s++)i=(+r.charAt(s)+t)%10,0===i&&(i=10),t=2*i%11;var l=1;return e=(t+ +r.slice(8,9))%10,e===l},rules:{regex:[/^(RS)(\d{9})$/]}},u.slovakia_republic={calcs:function(r){var e=0,t=r%11;return t===e},rules:{regex:[/^(SK)([1-9]\d[2346-9]\d{7})$/]}},u.slovenia={calcs:function(r){for(var e,t=0,i=0;i<7;i++)t+=+r.charAt(i)*this.rules.multipliers[i];return t=11-t%11,10===t&&(t=0),e=+r.slice(7,8),!(11===t||t!==e)},rules:{multipliers:[8,7,6,5,4,3,2],regex:[/^(SI)([1-9]\d{7})$/]}},u.spain={calcs:function(r){var e,t,i=0,s=0;if(this.rules.additional[0].test(r)){for(i=0;i<7;i++)e=r.charAt(i+1)*this.rules.multipliers[i],s+=e>9?Math.floor(e/10)+e%10:e;return s=10-s%10,10===s&&(s=0),t=+r.slice(8,9),s===t}if(this.rules.additional[1].test(r)){for(i=0;i<7;i++)e=r.charAt(i+1)*this.rules.multipliers[i],s+=e>9?Math.floor(e/10)+e%10:e;return s=10-s%10,s=String.fromCharCode(s+64),t=r.slice(8,9),s===t}if(this.rules.additional[2].test(r)){var l=r;return"Y"===l.substring(0,1)&&(l=l.replace(/Y/,"1")),"Z"===l.substring(0,1)&&(l=l.replace(/Z/,"2")),t="TRWAGMYFPDXBNJZSQVHLCKE".charAt(+l.substring(0,8)%23),l.charAt(8)===t}return!!this.rules.additional[3].test(r)&&(t="TRWAGMYFPDXBNJZSQVHLCKE".charAt(+r.substring(1,8)%23),r.charAt(8)===t)},rules:{multipliers:[2,1,2,1,2,1,2],regex:[/^(ES)([A-Z]\d{8})$/,/^(ES)([A-HN-SW]\d{7}[A-J])$/,/^(ES)([0-9YZ]\d{7}[A-Z])$/,/^(ES)([KLMX]\d{7}[A-Z])$/],additional:[/^[A-H|J|U|V]\d{8}$/,/^[A-H|N-S|W]\d{7}[A-J]$/,/^[0-9|Y|Z]\d{7}[A-Z]$/,/^[K|L|M|X]\d{7}[A-Z]$/]}},u.sweden={calcs:function(r){for(var e,t,i=0,s=0;s<9;s+=2)t=+r.charAt(s),i+=Math.floor(t/5)+2*t%10;for(var l=0,u=1;u<9;u+=2)l+=+r.charAt(u);var n=(10-(i+l)%10)%10;return e=+r.slice(9,10),n===e},rules:{regex:[/^(SE)(\d{10}01)$/]}},u.switzerland={calcs:function(r){for(var e=0,t=0;t<8;t++)e+=+r.charAt(t)*this.rules.multipliers[t];if(e=11-e%11,10===e)return!1;11===e&&(e=0);var i=+r.substr(8,1);return e===i},rules:{multipliers:[5,4,3,2,7,6,5,4],regex:[/^(CHE)(\d{9})(MWST)?$/]}},u.united_kingdom={calcs:function(r){var e,t=0;if("GD"===r.substr(0,2))return e=500,r.substr(2,3)<e;if("HA"===r.substr(0,2))return e=499,r.substr(2,3)>e;if(0===+r.slice(0))return!1;for(var i=+r.slice(0,7),s=0;s<7;s++)t+=+r.charAt(s)*this.rules.multipliers[s];for(var l=t;l>0;)l-=97;return l=Math.abs(l),l===+r.slice(7,9)&&i<9990001&&(i<1e5||i>999999)&&(i<9490001||i>97e5)||(l>=55?l-=55:l+=42,e=+r.slice(7,9),!!(l===e&&i>1e6))},rules:{multipliers:[8,7,6,5,4,3,2],regex:[/^(GB)?(\d{9})$/,/^(GB)?(\d{12})$/,/^(GB)?(GD\d{3})$/,/^(GB)?(HA\d{3})$/]}},"object"==typeof module&&module.exports&&(module.exports=n),n}();
//# sourceMappingURL=jsvat.min.js.map
{
"name": "jsvat",
"version": "1.1.2",
"version": "1.1.3",
"description": "Check the validity of the format of an EU VAT number",

@@ -5,0 +5,0 @@ "main": "./dist/jsvat.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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