itaibo / vies-checker

European VIES VAT number validator
https://npmjs.com/vies-checker
MIT License
4 stars 1 forks source link

Fix: `INVALID` userError handling #4

Closed pano9000 closed 1 year ago

pano9000 commented 1 year ago

Hi,

I noticed today, that the VIES service actually differentiates between INVALID and INVALID_INPUT userError messages:

in both cases, it should be fine to say that the VAT Check returned "false" – however in the current version, vies-checker will currently throw an error, when you run e.g. await isValid('ES', 'ABC123456') (valid country + invalid vat no -> which would return INVALID as userError value).

To fix this, I've adapted the list of "handled" userErrors accordingly.

I also updated the tests accordingly as well, to now test all 3 cases.

Let me know, if there are any questions.

Kind regards,

itaibo commented 1 year ago

I published a minor version with these changes. Thank you 😊