se-panfilov / jsvat

Check the validity of the format of an EU VAT number
http://se-panfilov.github.io/jsvat
MIT License
131 stars 34 forks source link

Only some countries working #86

Closed Aeners closed 5 years ago

Aeners commented 5 years ago

Hello there, I just installed this module, and I can't get it work for some countries.

Here is an example of returns I get:

import { checkVAT, countries } from 'jsvat';

console.log(checkVat('FRXX999999999', countries).isValid)   // => true
console.log(checkVat('DE999999999', countries).isValid)     // => false
console.log(checkVat('BE1234567890', countries).isValid)    // => false

Did I miss something ?

se-panfilov commented 5 years ago

Hi @Aeners ,

You've just killed my mind with the lower case in your example (you typed both checkVAT and checkVat, but it supposed to be checkVAT))) I literary spent an hour trying to understand how for the fucks sake checkVat could be undefined )) I guess I need a vacation... =)

Anyway, regarding your question.

I guess the problem with these lines

console.log(checkVat('DE999999999', countries).isValid)     // => false
console.log(checkVat('BE1234567890', countries).isValid)    // => false

Is simple - DE999999999 Isn't a valid VAT =) Same for BE1234567890.

In other words:

console.log(checkVAT('BE1234567890', countries).isValid)    // => false
console.log(checkVAT('BE0411905847', countries).isValid)    // => true

So the whole idea was to not let users input silly VATs, like 123456789.

So I assume the lib is working as expected, and I gonna close this issue )

If I didn't catch something - feel free to reopen it )