Comparing version 1.1.5 to 1.1.6
@@ -1,9 +0,9 @@ | ||
"use strict"; | ||
"use strict" | ||
const gulp = require('gulp'); | ||
const gulp = require('gulp') | ||
const config = require('../config'); | ||
const gzip = require('gulp-gzip'); | ||
const notify = require('gulp-notify'); | ||
const plumber = require('gulp-plumber'); | ||
const config = require('../config') | ||
const gzip = require('gulp-gzip') | ||
const notify = require('gulp-notify') | ||
const plumber = require('gulp-plumber') | ||
@@ -18,8 +18,8 @@ | ||
message: err.message | ||
}; | ||
} | ||
}) | ||
})) | ||
.pipe(gzip()) | ||
.pipe(gulp.dest(config.dest)); | ||
}); | ||
.pipe(gulp.dest(config.dest)) | ||
}) | ||
@@ -1,50 +0,50 @@ | ||
"use strict"; | ||
"use strict" | ||
const gulp = require('gulp'); | ||
const gulp = require('gulp') | ||
const config = require('../config'); | ||
const sourcemaps = require('gulp-sourcemaps'); | ||
const uglify = require('gulp-uglify'); | ||
const concat = require('gulp-concat'); | ||
const rename = require('gulp-rename'); | ||
const notify = require('gulp-notify'); | ||
const plumber = require('gulp-plumber'); | ||
const beautify = require('gulp-beautify'); | ||
const wrap = require('gulp-wrap'); | ||
const config = require('../config') | ||
const sourcemaps = require('gulp-sourcemaps') | ||
const uglify = require('gulp-uglify') | ||
const concat = require('gulp-concat') | ||
const rename = require('gulp-rename') | ||
const notify = require('gulp-notify') | ||
const plumber = require('gulp-plumber') | ||
const beautify = require('gulp-beautify') | ||
const wrap = require('gulp-wrap') | ||
gulp.task('js', function () { | ||
gulp.task('js', () => { | ||
const moduleWrap = | ||
'var jsvat = (function () {' + | ||
'\n\r\'use strict\';' + | ||
'\n\r<%= contents %>' + | ||
'\n\r//Support of node.js' + | ||
'\n\rif (typeof module === \'object\' && module.exports) module.exports = exports;' + | ||
'\n\rreturn exports;' + | ||
'\n\r})();'; | ||
'var jsvat = (function () {' + | ||
'\n\r\'use strict\'' + | ||
'\n\r<%= contents %>' + | ||
'\n\r//Support of node.js' + | ||
'\n\rif (typeof module === \'object\' && module.exports) module.exports = exports' + | ||
'\n\rreturn exports' + | ||
'\n\r})()' | ||
return gulp.src(config.js.src) | ||
.pipe(plumber({ | ||
errorHandler: notify.onError(function (err) { | ||
return { | ||
title: 'Build JS', | ||
message: err.message | ||
}; | ||
}) | ||
})) | ||
.pipe(concat(config.projectName + '.js')) | ||
.pipe(wrap(moduleWrap)) | ||
.pipe(beautify({ | ||
indent_size: 2 | ||
})) | ||
.pipe(gulp.dest(config.dest)) | ||
.pipe(sourcemaps.init()) | ||
.pipe(uglify()) | ||
.pipe(rename({basename: config.projectName + '.min'})) | ||
.pipe(gulp.dest(config.dest)) | ||
.pipe(sourcemaps.write('.')) | ||
.pipe(gulp.dest(config.dest)) | ||
; | ||
.pipe(plumber({ | ||
errorHandler: notify.onError((err) => { | ||
return { | ||
title: 'Build JS', | ||
message: err.message | ||
} | ||
}) | ||
})) | ||
.pipe(concat(config.projectName + '.js')) | ||
.pipe(wrap(moduleWrap)) | ||
.pipe(beautify({ | ||
indent_size: 2 | ||
})) | ||
.pipe(gulp.dest(config.dest)) | ||
.pipe(sourcemaps.init()) | ||
.pipe(uglify()) | ||
.pipe(rename({basename: config.projectName + '.min'})) | ||
.pipe(gulp.dest(config.dest)) | ||
.pipe(sourcemaps.write('.')) | ||
.pipe(gulp.dest(config.dest)) | ||
}); | ||
}) | ||
@@ -1,10 +0,10 @@ | ||
"use strict"; | ||
"use strict" | ||
const gulp = require('gulp'); | ||
const gulp = require('gulp') | ||
const config = require('../config'); | ||
const buddyjs = require('gulp-buddy.js'); | ||
const config = require('../config') | ||
const buddyjs = require('gulp-buddy.js') | ||
gulp.task('magic_numbers', function () { | ||
gulp.task('magic_numbers', () => { | ||
@@ -15,3 +15,3 @@ return gulp.src(config.js.src) | ||
reporter: 'detailed' | ||
})); | ||
}); | ||
})) | ||
}) |
@@ -1,13 +0,13 @@ | ||
"use strict"; | ||
"use strict" | ||
const gulp = require('gulp'); | ||
const runSequence = require('run-sequence').use(gulp); | ||
const config = require('../config'); | ||
const gulp = require('gulp') | ||
const runSequence = require('run-sequence').use(gulp) | ||
const config = require('../config') | ||
gulp.task('make', function () { | ||
gulp.task('make', () => { | ||
return runSequence( | ||
'js', | ||
'gzip' | ||
); | ||
}); | ||
) | ||
}) |
@@ -1,13 +0,13 @@ | ||
"use strict"; | ||
"use strict" | ||
const gulp = require('gulp'); | ||
const gulp = require('gulp') | ||
const size = require('gulp-size'); | ||
const size = require('gulp-size') | ||
gulp.task('sizes', function () { | ||
gulp.task('sizes', () => { | ||
return gulp.src([ | ||
'dist/**/*.js', | ||
'dist/**/*.gz' | ||
]).pipe(size({showFiles: true, showTotal: true})); | ||
}); | ||
]).pipe(size({showFiles: true, showTotal: true})) | ||
}) |
@@ -1,13 +0,13 @@ | ||
"use strict"; | ||
"use strict" | ||
const gulp = require('gulp'); | ||
const config = require('../config'); | ||
const todo = require('gulp-todo'); | ||
const gulp = require('gulp') | ||
const config = require('../config') | ||
const todo = require('gulp-todo') | ||
gulp.task('todo', function () { | ||
const src = config.js.src.concat([config.tests.src[0] + '/**/*.js']).concat(['tasks/**/*.js']); | ||
gulp.task('todo', () => { | ||
const src = config.js.src.concat([config.tests.src[0] + '/**/*.js']).concat(['tasks/**/*.js']) | ||
return gulp.src(src) | ||
.pipe(todo()) | ||
.pipe(gulp.dest('./')); | ||
}); | ||
.pipe(gulp.dest('./')) | ||
}) |
var jsvat = (function() { | ||
'use strict'; | ||
'use strict' | ||
@@ -26,3 +26,3 @@ var COUNTRIES = {} | ||
function _getPureVAT(vat) { | ||
function removeExtraChars(vat) { | ||
vat = vat || '' | ||
@@ -50,6 +50,8 @@ return vat.toString().toUpperCase().replace(/(\s|-|\.)+/g, '') | ||
checkVAT: function(vat) { | ||
var cleanVAT = removeExtraChars(vat) | ||
var result = { | ||
value: _getPureVAT(vat), | ||
value: cleanVAT, | ||
isValid: false, | ||
country: null | ||
country: null, | ||
countryCode: null | ||
} | ||
@@ -59,2 +61,5 @@ | ||
var ccArr = (/^([A-z])*/).exec(cleanVAT) | ||
if (ccArr && ccArr.length > 0) result.countryCode = ccArr[0].toUpperCase() | ||
for (var countryName in COUNTRIES) { | ||
@@ -1631,6 +1636,6 @@ if (COUNTRIES.hasOwnProperty(countryName)) { | ||
if (typeof module === 'object' && module.exports) module.exports = exports; | ||
if (typeof module === 'object' && module.exports) module.exports = exports | ||
return exports; | ||
return exports | ||
})(); | ||
})() |
@@ -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)&&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}(); | ||
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=i(r),t={value:e,isValid:!1,country:null,countryCode:null};if(!r)return t;var s=/^([A-z])*/.exec(e);s&&s.length>0&&(t.countryCode=s[0].toUpperCase());for(var n in u)if(u.hasOwnProperty(n)&&(t.isValid=l(t.value,n),t.isValid))return t.country=n,t;return t}};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){return 9===r.length&&(r="0"+r),0!=+r.slice(1,2)&&97-+r.slice(0,8)%97==+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),10!==(t=i%11)?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){if(e(0,r,0,9,t.multipliers.foreigner)%10==+r.substr(9,1))return!0}function l(r,t){var i=e(0,r,0,9,t.multipliers.miscellaneous);return 10!=(i=11-i%11)&&(11===i&&(i=0),i===+r.substr(9,1))}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);return t===+r.slice(7,8)}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))<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);return l===+r.slice(8,9)}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);return t===+r.slice(11,12)}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);return+r.slice(0,6)%89===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);return t===+r.slice(9,10)}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=10,t=0,i=0;i<8;i++)t=(+r.charAt(i)+e)%10,0===t&&(t=10),e=2*t%11;return 1===(e+ +r.slice(8,9))%10},rules:{regex:[/^(RS)(\d{9})$/]}},u.slovakia_republic={calcs:function(r){return 0==r%11},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];return 10!=(e=11-e%11)&&(11===e&&(e=0),e===+r.substr(8,1))},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))===+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 |
@@ -1,17 +0,17 @@ | ||
'use strict'; | ||
'use strict' | ||
var gulp = require('gulp'); | ||
var config = require('./build/config.js'); | ||
var requireDir = require('require-dir'); | ||
requireDir('./build', { recurse: true }); | ||
const gulp = require('gulp') | ||
const config = require('./build/config.js') | ||
const requireDir = require('require-dir') | ||
requireDir('./build', { recurse: true }) | ||
gulp.task('default', function () { | ||
gulp.start('make'); | ||
gulp.start('watch'); | ||
}); | ||
gulp.start('make') | ||
gulp.start('watch') | ||
}) | ||
gulp.task('watch', function () { | ||
var watch = require('gulp-watch'); | ||
const watch = require('gulp-watch') | ||
gulp.watch(config.js.src, ['js', 'todo']); | ||
}); | ||
gulp.watch(config.js.src, ['js', 'todo']) | ||
}) |
{ | ||
"name": "jsvat", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "Check the validity of the format of an EU VAT number", | ||
@@ -55,10 +55,10 @@ "main": "./dist/jsvat.js", | ||
"gulp-todo": "^5.3.0", | ||
"gulp-uglify": "^2.0.1", | ||
"gulp-uglify": "^2.1.0", | ||
"gulp-watch": "^4.3.11", | ||
"gulp-webstandards": "^0.1.1", | ||
"gulp-wrap": "^0.13.0", | ||
"eslint": "^3.14.1", | ||
"eslint-config-standard": "^6.2.1", | ||
"eslint-plugin-promise": "^3.4.0", | ||
"eslint-plugin-standard": "^2.0.1", | ||
"eslint": "^3.17.1", | ||
"eslint-config-standard": "^7.0.1", | ||
"eslint-plugin-promise": "^3.5.0", | ||
"eslint-plugin-standard": "^2.1.1", | ||
"minimist": "^1.2.0", | ||
@@ -65,0 +65,0 @@ "mocha": "^3.2.0", |
@@ -34,6 +34,6 @@ [![Codacy Badge](https://api.codacy.com/project/badge/grade/874e7dce623149e18807bdc0a02671c2)](https://www.codacy.com/app/se-panfilov/jsvat) | ||
```javascript | ||
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'} | ||
jsvat.checkVAT('BG131134023'); // {isValid: true, country: 'bulgaria', value: 'BG131134023', countryCode: 'BG'} | ||
jsvat.checkVAT('BG0433170001'); //{isValid: false, country: null, value: 'BG0433170001', countryCode: 'BG'} | ||
jsvat.checkVAT('atu5-150-7409'); //{isValid: true, country: 'austria', value: 'ATU51507409', countryCode: 'ATU'} | ||
jsvat.checkVAT('aTU 5 804 4146'); //{isValid: true, country: 'austria', value: 'ATU58044146', countryCode: 'ATU'} | ||
``` | ||
@@ -47,5 +47,5 @@ | ||
``` | ||
To reset config just do `jsvat.config = [];` | ||
Installation | ||
@@ -71,10 +71,10 @@ ---------- | ||
----- | ||
It's simple: | ||
It's simple: | ||
```javascript | ||
jsvat.chcekVat(vat); //returns Object | ||
jsvat.checkVAT(vat); //returns Object | ||
``` | ||
- `vat` param means VAT number (`string`), like "BG0433170001". | ||
- `vat` param means VAT number (`string`), like "BG0433170001". | ||
`vat` can be passed with '-' (`BG0-4331-70001`) or ' ' (space, like `BG 0433 17 0001`) characters; | ||
@@ -91,9 +91,9 @@ | ||
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. | ||
Looks like `ATU99999999` is valid (it's satisfy the regexp), but actually it's should be invalid. | ||
2. Some magic mathematical counting; | ||
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. | ||
After that we may be sure that `ATU99999999`and for example `ATV66889218` isn't valid, but `ATU12011204` is valid. | ||
@@ -135,3 +135,3 @@ List of supported Countries: | ||
- Sweden | ||
Versions for frameworks: | ||
@@ -150,5 +150,5 @@ -------- | ||
#####1.1.0 | ||
#####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); | ||
- Changed way of jsvat configuration (instead of object with countries, now you should pass an array with list of allowed countries); | ||
@@ -155,0 +155,0 @@ LICENSE |
@@ -22,3 +22,3 @@ var COUNTRIES = {} | ||
function _getPureVAT (vat) { | ||
function removeExtraChars (vat) { | ||
vat = vat || '' | ||
@@ -46,6 +46,8 @@ return vat.toString().toUpperCase().replace(/(\s|-|\.)+/g, '') | ||
checkVAT: function (vat) { | ||
var cleanVAT = removeExtraChars(vat) | ||
var result = { | ||
value: _getPureVAT(vat), | ||
value: cleanVAT, | ||
isValid: false, | ||
country: null | ||
country: null, | ||
countryCode: null | ||
} | ||
@@ -55,2 +57,5 @@ | ||
var ccArr = (/^([A-z])*/).exec(cleanVAT) | ||
if (ccArr && ccArr.length > 0) result.countryCode = ccArr[0].toUpperCase() | ||
for (var countryName in COUNTRIES) { | ||
@@ -57,0 +62,0 @@ if (COUNTRIES.hasOwnProperty(countryName)) { |
module.exports = { | ||
valid: [ | ||
'ATU00000024', | ||
'ATU00000033', | ||
'ATU00000042', | ||
'ATU00000202', | ||
'ATU00000060', | ||
'ATU00000079', | ||
'ATU00000088', | ||
'ATU00000104', | ||
'ATU00000113', | ||
'ATU00000122', | ||
'ATU00000140', | ||
'ATU00000159', | ||
'ATU00000168', | ||
'ATU00000186', | ||
'ATU00000195', | ||
'ATU00000202', | ||
'ATU12011204', | ||
'ATU10223006', | ||
'ATU15110001', | ||
'ATU15394605', | ||
'ATU15416707', | ||
'ATU15662209', | ||
'ATU16370905', | ||
'ATU23224909', | ||
'ATU25775505', | ||
'ATU28560205', | ||
'ATU28609707', | ||
'ATU28617100', | ||
'ATU29288909', | ||
'ATU37675002', | ||
'ATU37785508', | ||
'ATU37830200', | ||
'ATU38420507', | ||
'ATU38516405', | ||
'ATU39364503', | ||
'ATU42527002', | ||
'ATU43666001', | ||
'ATU43716207', | ||
'ATU45766309', | ||
'ATU47977701', | ||
'ATU49487700', | ||
'ATU51009402', | ||
'ATU51507409', | ||
'ATU51749808', | ||
'ATU52699307', | ||
'ATU57477929', | ||
'ATU58044146', | ||
'ATU61255233', | ||
'ATU61993034', | ||
'ATU62134737', | ||
'ATU62593358', | ||
'ATU62765626', | ||
'ATU62895905', | ||
'ATU62927729', | ||
'ATU63436026', | ||
'ATU64487479', | ||
'ATU64762368', | ||
'ATU64727905', | ||
'ATU64938189', | ||
'ATU66664013', | ||
'ATU66889218' | ||
'ATU00000024' | ||
], | ||
invalid: [ | ||
'ATV66889218', | ||
'ATU10223001', | ||
'ATU10223002', | ||
'ATU10223003', | ||
'ATU10223004', | ||
'ATU10223005', | ||
'ATU10223007' | ||
] | ||
}; | ||
@@ -1,45 +0,45 @@ | ||
'use strict'; | ||
'use strict' | ||
var jsvat = require('../../dist/jsvat.js'); | ||
var utils = require('../utils.js'); | ||
var jsvat = require('../../dist/jsvat.js') | ||
var utils = require('../utils.js') | ||
var countries = {}; | ||
countries.austria = require('./countries_vat_lists/austria.vat.js'); | ||
countries.belgium = require('./countries_vat_lists/belgium.vat.js'); | ||
countries.bulgaria = require('./countries_vat_lists/bulgaria.vat.js'); | ||
countries.croatia = require('./countries_vat_lists/croatia.vat.js'); | ||
countries.cyprus = require('./countries_vat_lists/cyprus.vat.js'); | ||
countries.czech_republic = require('./countries_vat_lists/czech_republic.vat.js'); | ||
countries.denmark = require('./countries_vat_lists/denmark.vat.js'); | ||
countries.estonia = require('./countries_vat_lists/estonia.vat.js'); | ||
countries.europe = require('./countries_vat_lists/europe.vat.js'); | ||
countries.finland = require('./countries_vat_lists/finland.vat.js'); | ||
countries.france = require('./countries_vat_lists/france.vat.js'); | ||
countries.germany = require('./countries_vat_lists/germany.vat.js'); | ||
countries.greece = require('./countries_vat_lists/greece.vat.js'); | ||
countries.hungary = require('./countries_vat_lists/hungary.vat.js'); | ||
countries.ireland = require('./countries_vat_lists/ireland.vat.js'); | ||
countries.italy = require('./countries_vat_lists/italy.vat.js'); | ||
countries.latvia = require('./countries_vat_lists/latvia.vat.js'); | ||
countries.lithunia = require('./countries_vat_lists/lithunia.vat.js'); | ||
countries.luxembourg = require('./countries_vat_lists/luxembourg.vat.js'); | ||
countries.malta = require('./countries_vat_lists/malta.vat.js'); | ||
countries.netherlands = require('./countries_vat_lists/netherlands.vat.js'); | ||
countries.norway = require('./countries_vat_lists/norway.vat.js'); | ||
countries.poland = require('./countries_vat_lists/poland.vat.js'); | ||
countries.portugal = require('./countries_vat_lists/portugal.vat.js'); | ||
countries.romania = require('./countries_vat_lists/romania.vat.js'); | ||
countries.russia = require('./countries_vat_lists/russia.vat.js'); | ||
countries.serbia = require('./countries_vat_lists/serbia.vat.js'); | ||
countries.slovakia_republic = require('./countries_vat_lists/slovakia.vat.js'); | ||
countries.slovenia = require('./countries_vat_lists/slovenia.vat.js'); | ||
countries.spain = require('./countries_vat_lists/spain.vat.js'); | ||
countries.sweden = require('./countries_vat_lists/sweden.vat.js'); | ||
countries.switzerland = require('./countries_vat_lists/switzerland.vat.js'); | ||
countries.united_kingdom = require('./countries_vat_lists/united_kingdom.vat.js'); | ||
var countries = {} | ||
countries.austria = require('./countries_vat_lists/austria.vat.js') | ||
countries.belgium = require('./countries_vat_lists/belgium.vat.js') | ||
countries.bulgaria = require('./countries_vat_lists/bulgaria.vat.js') | ||
countries.croatia = require('./countries_vat_lists/croatia.vat.js') | ||
countries.cyprus = require('./countries_vat_lists/cyprus.vat.js') | ||
countries.czech_republic = require('./countries_vat_lists/czech_republic.vat.js') | ||
countries.denmark = require('./countries_vat_lists/denmark.vat.js') | ||
countries.estonia = require('./countries_vat_lists/estonia.vat.js') | ||
countries.europe = require('./countries_vat_lists/europe.vat.js') | ||
countries.finland = require('./countries_vat_lists/finland.vat.js') | ||
countries.france = require('./countries_vat_lists/france.vat.js') | ||
countries.germany = require('./countries_vat_lists/germany.vat.js') | ||
countries.greece = require('./countries_vat_lists/greece.vat.js') | ||
countries.hungary = require('./countries_vat_lists/hungary.vat.js') | ||
countries.ireland = require('./countries_vat_lists/ireland.vat.js') | ||
countries.italy = require('./countries_vat_lists/italy.vat.js') | ||
countries.latvia = require('./countries_vat_lists/latvia.vat.js') | ||
countries.lithunia = require('./countries_vat_lists/lithunia.vat.js') | ||
countries.luxembourg = require('./countries_vat_lists/luxembourg.vat.js') | ||
countries.malta = require('./countries_vat_lists/malta.vat.js') | ||
countries.netherlands = require('./countries_vat_lists/netherlands.vat.js') | ||
countries.norway = require('./countries_vat_lists/norway.vat.js') | ||
countries.poland = require('./countries_vat_lists/poland.vat.js') | ||
countries.portugal = require('./countries_vat_lists/portugal.vat.js') | ||
countries.romania = require('./countries_vat_lists/romania.vat.js') | ||
countries.russia = require('./countries_vat_lists/russia.vat.js') | ||
countries.serbia = require('./countries_vat_lists/serbia.vat.js') | ||
countries.slovakia_republic = require('./countries_vat_lists/slovakia.vat.js') | ||
countries.slovenia = require('./countries_vat_lists/slovenia.vat.js') | ||
countries.spain = require('./countries_vat_lists/spain.vat.js') | ||
countries.sweden = require('./countries_vat_lists/sweden.vat.js') | ||
countries.switzerland = require('./countries_vat_lists/switzerland.vat.js') | ||
countries.united_kingdom = require('./countries_vat_lists/united_kingdom.vat.js') | ||
for (var countryName in countries) { | ||
for (const countryName in countries) { | ||
if (countries.hasOwnProperty(countryName)) { | ||
var vatList = countries[countryName]; | ||
makeTests(vatList, countryName); | ||
const vatList = countries[countryName] | ||
makeTests(vatList, countryName) | ||
} | ||
@@ -49,263 +49,263 @@ } | ||
function makeTests(vatList, countryName) { | ||
describe(countryName + ' VAT.', function () { | ||
describe('Common checks.', function () { | ||
describe('Valid VAT.', function () { | ||
describe(countryName + ' VAT.', () => { | ||
describe('Common checks.', () => { | ||
describe('Valid VAT.', () => { | ||
describe('Simple checks.', function () { | ||
describe('Regular valid VAT.', function () { | ||
utils.check(vatList.valid, 'Is VAT valid', true, countryName); | ||
}); | ||
describe('Simple checks.', () => { | ||
describe('Regular valid VAT.', () => { | ||
utils.check(vatList.valid, 'Is VAT valid', true, countryName) | ||
}) | ||
describe('Valid VAT with \'-\' character.', function () { | ||
utils.check(utils.addCharsToVals(vatList.valid, '-'), 'Is VAT valid', true, countryName); | ||
}); | ||
describe('Valid VAT with space character.', function () { | ||
utils.check(utils.addCharsToVals(vatList.valid, ' '), 'Is VAT valid', true, countryName); | ||
}); | ||
}); | ||
}); | ||
describe('Valid VAT with \'-\' character.', () => { | ||
utils.check(utils.addCharsToVals(vatList.valid, '-'), 'Is VAT valid', true, countryName) | ||
}) | ||
describe('Invalid VAT.', function () { | ||
describe('Simple checks.', function () { | ||
describe('Regular valid VAT.', function () { | ||
utils.check(vatList.invalid, 'Is VAT valid', false, countryName); | ||
}); | ||
describe('Valid VAT with \'-\' character.', function () { | ||
utils.check(utils.addCharsToVals(vatList.invalid, '-'), 'Is VAT valid', false, countryName); | ||
}); | ||
describe('Valid VAT with space character.', function () { | ||
utils.check(utils.addCharsToVals(vatList.invalid, ' '), 'Is VAT valid', false, countryName); | ||
}); | ||
}); | ||
}); | ||
describe('Valid VAT with space character.', () => { | ||
utils.check(utils.addCharsToVals(vatList.valid, ' '), 'Is VAT valid', true, countryName) | ||
}) | ||
}) | ||
}) | ||
}); | ||
describe('Invalid VAT.', () => { | ||
describe('Isolated VAT checks.', function () { | ||
describe('Config include current country.', function () { | ||
before(function () { | ||
jsvat.config = []; | ||
jsvat.config.push(countryName); | ||
}); | ||
describe('Valid VAT.', function () { | ||
describe('Simple checks.', function () { | ||
describe('Regular valid VAT.', function () { | ||
utils.check(vatList.valid, 'Is VAT valid', true, countryName); | ||
}); | ||
describe('Valid VAT with \'-\' character.', function () { | ||
utils.check(utils.addCharsToVals(vatList.valid, '-'), 'Is VAT valid', true, countryName); | ||
}); | ||
describe('Valid VAT with space character.', function () { | ||
utils.check(utils.addCharsToVals(vatList.valid, ' '), 'Is VAT valid', true, countryName); | ||
}); | ||
}); | ||
}); | ||
describe('Invalid VAT.', function () { | ||
describe('Simple checks.', function () { | ||
describe('Regular valid VAT.', function () { | ||
utils.check(vatList.invalid, 'Is VAT valid', false, countryName); | ||
}); | ||
describe('Valid VAT with \'-\' character.', function () { | ||
utils.check(utils.addCharsToVals(vatList.invalid, '-'), 'Is VAT valid', false, countryName); | ||
}); | ||
describe('Valid VAT with space character.', function () { | ||
utils.check(utils.addCharsToVals(vatList.invalid, ' '), 'Is VAT valid', false, countryName); | ||
}); | ||
}); | ||
}); | ||
after(function () { | ||
jsvat.config = []; | ||
}); | ||
}); | ||
describe('Config exclude current country.', function () { | ||
before(function () { | ||
jsvat.config = []; | ||
describe('Simple checks.', () => { | ||
describe('Regular valid VAT.', () => { | ||
utils.check(vatList.invalid, 'Is VAT valid', false, countryName) | ||
}) | ||
describe('Valid VAT with \'-\' character.', () => { | ||
utils.check(utils.addCharsToVals(vatList.invalid, '-'), 'Is VAT valid', false, countryName) | ||
}) | ||
describe('Valid VAT with space character.', () => { | ||
utils.check(utils.addCharsToVals(vatList.invalid, ' '), 'Is VAT valid', false, countryName) | ||
}) | ||
}) | ||
}) | ||
}) | ||
describe('Isolated VAT checks.', () => { | ||
describe('Config include current country.', () => { | ||
before(() => { | ||
jsvat.config = [] | ||
jsvat.config.push(countryName) | ||
}); | ||
describe('Valid VAT.', function () { | ||
describe('Simple checks.', function () { | ||
describe('Regular valid VAT.', function () { | ||
utils.check(vatList.valid, 'Is VAT valid', true, countryName); | ||
}); | ||
describe('Valid VAT with \'-\' character.', function () { | ||
utils.check(utils.addCharsToVals(vatList.valid, '-'), 'Is VAT valid', true, countryName); | ||
}); | ||
describe('Valid VAT with space character.', function () { | ||
utils.check(utils.addCharsToVals(vatList.valid, ' '), 'Is VAT valid', true, countryName); | ||
}); | ||
}); | ||
}); | ||
describe('Invalid VAT.', function () { | ||
describe('Simple checks.', function () { | ||
describe('Regular valid VAT.', function () { | ||
utils.check(vatList.invalid, 'Is VAT valid', false, countryName); | ||
}); | ||
describe('Valid VAT with \'-\' character.', function () { | ||
utils.check(utils.addCharsToVals(vatList.invalid, '-'), 'Is VAT valid', false, countryName); | ||
}); | ||
describe('Valid VAT with space character.', function () { | ||
utils.check(utils.addCharsToVals(vatList.invalid, ' '), 'Is VAT valid', false, countryName); | ||
}); | ||
}); | ||
}); | ||
after(function () { | ||
jsvat.config = []; | ||
}); | ||
}); | ||
describe('Config include other country.', function () { | ||
before(function () { | ||
var otherCountry = 'sweden'; | ||
jsvat.config = []; | ||
}) | ||
describe('Valid VAT.', () => { | ||
describe('Simple checks.', () => { | ||
describe('Regular valid VAT.', () => { | ||
utils.check(vatList.valid, 'Is VAT valid', true, countryName) | ||
}) | ||
describe('Valid VAT with \'-\' character.', () => { | ||
utils.check(utils.addCharsToVals(vatList.valid, '-'), 'Is VAT valid', true, countryName) | ||
}) | ||
describe('Valid VAT with space character.', () => { | ||
utils.check(utils.addCharsToVals(vatList.valid, ' '), 'Is VAT valid', true, countryName) | ||
}) | ||
}) | ||
}) | ||
describe('Invalid VAT.', () => { | ||
describe('Simple checks.', () => { | ||
describe('Regular valid VAT.', () => { | ||
utils.check(vatList.invalid, 'Is VAT valid', false, countryName) | ||
}) | ||
describe('Valid VAT with \'-\' character.', () => { | ||
utils.check(utils.addCharsToVals(vatList.invalid, '-'), 'Is VAT valid', false, countryName) | ||
}) | ||
describe('Valid VAT with space character.', () => { | ||
utils.check(utils.addCharsToVals(vatList.invalid, ' '), 'Is VAT valid', false, countryName) | ||
}) | ||
}) | ||
}) | ||
after(() => { | ||
jsvat.config = [] | ||
}) | ||
}) | ||
describe('Config exclude current country.', () => { | ||
before(() => { | ||
jsvat.config = [] | ||
jsvat.config.push(countryName) | ||
}) | ||
describe('Valid VAT.', () => { | ||
describe('Simple checks.', () => { | ||
describe('Regular valid VAT.', () => { | ||
utils.check(vatList.valid, 'Is VAT valid', true, countryName) | ||
}) | ||
describe('Valid VAT with \'-\' character.', () => { | ||
utils.check(utils.addCharsToVals(vatList.valid, '-'), 'Is VAT valid', true, countryName) | ||
}) | ||
describe('Valid VAT with space character.', () => { | ||
utils.check(utils.addCharsToVals(vatList.valid, ' '), 'Is VAT valid', true, countryName) | ||
}) | ||
}) | ||
}) | ||
describe('Invalid VAT.', () => { | ||
describe('Simple checks.', () => { | ||
describe('Regular valid VAT.', () => { | ||
utils.check(vatList.invalid, 'Is VAT valid', false, countryName) | ||
}) | ||
describe('Valid VAT with \'-\' character.', () => { | ||
utils.check(utils.addCharsToVals(vatList.invalid, '-'), 'Is VAT valid', false, countryName) | ||
}) | ||
describe('Valid VAT with space character.', () => { | ||
utils.check(utils.addCharsToVals(vatList.invalid, ' '), 'Is VAT valid', false, countryName) | ||
}) | ||
}) | ||
}) | ||
after(() => { | ||
jsvat.config = [] | ||
}) | ||
}) | ||
describe('Config include other country.', () => { | ||
before(() => { | ||
var otherCountry = 'sweden' | ||
jsvat.config = [] | ||
if (countryName === 'sweden') { | ||
otherCountry = 'austria'; | ||
otherCountry = 'austria' | ||
} | ||
jsvat.config.push(otherCountry) | ||
}); | ||
describe('Valid VAT.', function () { | ||
describe('Simple checks.', function () { | ||
describe('Regular valid VAT.', function () { | ||
utils.check(vatList.valid, 'Is VAT valid', false, countryName); | ||
}); | ||
describe('Valid VAT with \'-\' character.', function () { | ||
utils.check(utils.addCharsToVals(vatList.valid, '-'), 'Is VAT valid', false, countryName); | ||
}); | ||
describe('Valid VAT with space character.', function () { | ||
utils.check(utils.addCharsToVals(vatList.valid, ' '), 'Is VAT valid', false, countryName); | ||
}); | ||
}); | ||
}); | ||
describe('Invalid VAT.', function () { | ||
describe('Simple checks.', function () { | ||
describe('Regular valid VAT.', function () { | ||
utils.check(vatList.invalid, 'Is VAT valid', false, countryName); | ||
}); | ||
describe('Valid VAT with \'-\' character.', function () { | ||
utils.check(utils.addCharsToVals(vatList.invalid, '-'), 'Is VAT valid', false, countryName); | ||
}); | ||
describe('Valid VAT with space character.', function () { | ||
utils.check(utils.addCharsToVals(vatList.invalid, ' '), 'Is VAT valid', false, countryName); | ||
}); | ||
}); | ||
}); | ||
after(function () { | ||
jsvat.config = []; | ||
}); | ||
}); | ||
describe('Config include multiple countries VAT checks.', function () { | ||
before(function () { | ||
var otherCountries = ['sweden', 'russia', 'united_kingdom']; | ||
jsvat.config = []; | ||
if (countryName === 'sweden') otherCountries[0] = 'austria'; | ||
if (countryName === 'russia') otherCountries[1] = 'austria'; | ||
if (countryName === 'united_kingdom') otherCountries[2] = 'austria'; | ||
jsvat.config.push(otherCountries[0]); | ||
jsvat.config.push(otherCountries[1]); | ||
jsvat.config.push(otherCountries[2]); | ||
}); | ||
describe('Valid VAT.', function () { | ||
describe('Simple checks.', function () { | ||
describe('Regular valid VAT.', function () { | ||
utils.check(vatList.valid, 'Is VAT valid', false, countryName); | ||
}); | ||
describe('Valid VAT with \'-\' character.', function () { | ||
utils.check(utils.addCharsToVals(vatList.valid, '-'), 'Is VAT valid', false, countryName); | ||
}); | ||
describe('Valid VAT with space character.', function () { | ||
utils.check(utils.addCharsToVals(vatList.valid, ' '), 'Is VAT valid', false, countryName); | ||
}); | ||
}); | ||
}); | ||
describe('Invalid VAT.', function () { | ||
describe('Simple checks.', function () { | ||
describe('Regular valid VAT.', function () { | ||
utils.check(vatList.invalid, 'Is VAT valid', false, countryName); | ||
}); | ||
describe('Valid VAT with \'-\' character.', function () { | ||
utils.check(utils.addCharsToVals(vatList.invalid, '-'), 'Is VAT valid', false, countryName); | ||
}); | ||
describe('Valid VAT with space character.', function () { | ||
utils.check(utils.addCharsToVals(vatList.invalid, ' '), 'Is VAT valid', false, countryName); | ||
}); | ||
}); | ||
}); | ||
after(function () { | ||
jsvat.config = []; | ||
}); | ||
}); | ||
}); | ||
}) | ||
}); | ||
} | ||
describe('Valid VAT.', () => { | ||
describe('Simple checks.', () => { | ||
describe('Regular valid VAT.', () => { | ||
utils.check(vatList.valid, 'Is VAT valid', false, countryName) | ||
}) | ||
describe('Valid VAT with \'-\' character.', () => { | ||
utils.check(utils.addCharsToVals(vatList.valid, '-'), 'Is VAT valid', false, countryName) | ||
}) | ||
describe('Valid VAT with space character.', () => { | ||
utils.check(utils.addCharsToVals(vatList.valid, ' '), 'Is VAT valid', false, countryName) | ||
}) | ||
}) | ||
}) | ||
describe('Invalid VAT.', () => { | ||
describe('Simple checks.', () => { | ||
describe('Regular valid VAT.', () => { | ||
utils.check(vatList.invalid, 'Is VAT valid', false, countryName) | ||
}) | ||
describe('Valid VAT with \'-\' character.', () => { | ||
utils.check(utils.addCharsToVals(vatList.invalid, '-'), 'Is VAT valid', false, countryName) | ||
}) | ||
describe('Valid VAT with space character.', () => { | ||
utils.check(utils.addCharsToVals(vatList.invalid, ' '), 'Is VAT valid', false, countryName) | ||
}) | ||
}) | ||
}) | ||
after(() => { | ||
jsvat.config = [] | ||
}) | ||
}) | ||
describe('Config include multiple countries VAT checks.', () => { | ||
before(() => { | ||
var otherCountries = ['sweden', 'russia', 'united_kingdom'] | ||
jsvat.config = [] | ||
if (countryName === 'sweden') otherCountries[0] = 'austria' | ||
if (countryName === 'russia') otherCountries[1] = 'austria' | ||
if (countryName === 'united_kingdom') otherCountries[2] = 'austria' | ||
jsvat.config.push(otherCountries[0]) | ||
jsvat.config.push(otherCountries[1]) | ||
jsvat.config.push(otherCountries[2]) | ||
}) | ||
describe('Valid VAT.', () => { | ||
describe('Simple checks.', () => { | ||
describe('Regular valid VAT.', () => { | ||
utils.check(vatList.valid, 'Is VAT valid', false, countryName) | ||
}) | ||
describe('Valid VAT with \'-\' character.', () => { | ||
utils.check(utils.addCharsToVals(vatList.valid, '-'), 'Is VAT valid', false, countryName) | ||
}) | ||
describe('Valid VAT with space character.', () => { | ||
utils.check(utils.addCharsToVals(vatList.valid, ' '), 'Is VAT valid', false, countryName) | ||
}) | ||
}) | ||
}) | ||
describe('Invalid VAT.', () => { | ||
describe('Simple checks.', () => { | ||
describe('Regular valid VAT.', () => { | ||
utils.check(vatList.invalid, 'Is VAT valid', false, countryName) | ||
}) | ||
describe('Valid VAT with \'-\' character.', () => { | ||
utils.check(utils.addCharsToVals(vatList.invalid, '-'), 'Is VAT valid', false, countryName) | ||
}) | ||
describe('Valid VAT with space character.', () => { | ||
utils.check(utils.addCharsToVals(vatList.invalid, ' '), 'Is VAT valid', false, countryName) | ||
}) | ||
}) | ||
}) | ||
after(() => { | ||
jsvat.config = [] | ||
}) | ||
}) | ||
}) | ||
}) | ||
} |
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
403173
101
5445