Open Pouch opened 4 years ago
The code currently prepends the zero to the vat if it is missing: https://github.com/se-panfilov/jsvat/blob/65e584b37798a2b0aeb7bf1d237d743d0b5111a3/src/lib/countries/belgium.ts#L7
Is that wrong?
Ok that explains why the validator returns true.
Actually, depending on the user's input, the validator is updating it to fit the country's rule. But it implies that the developer must know all formating rules for all countries because the validator will transforms it before validating step. I don't know if it was a request from developers or from you to implement it but is there a way to get a field saying that "the initial input was modified before passing the validation" ?
Because both isValid & isValidFormat fields return true in the actual implementation.
There is an issue with the vat validation for Belgium. Actually, vat format is BE0 + 9 numbers.
Using your validator with the example :
checkVAT('BE0411905847', [belgium]); // true: accept only Belgium VATs
is working but the issue is with this format (without the zero)checkVAT('BE411905847', [belgium]); // return true but should be false