mattickx / jsvat-next

Check the validity of the format of an EU VAT number
MIT License
14 stars 0 forks source link

Belgium vat validation issue #5

Closed mattickx closed 9 months ago

mattickx commented 11 months ago

See parent/forked repo: https://github.com/se-panfilov/jsvat/issues/104

I ask to the community, is this something we want ?

pere-pleo commented 11 months ago

Is the question if we want the BE VAT input validation without the 0 to fail or if we want the validation to pass but somehow signal that the initial input was invalid? Asking because the latter was suggested here.

mattickx commented 11 months ago

Is the question if we want the BE VAT input validation without the 0 to fail or if we want the validation to pass but somehow signal that the initial input was invalid?

I'm also wondering if Belgium is the only country we change such input?

I would suggest having strict validation in any case, without changing the input value.

So validating based on formats: BE0 + 9 numbers OR BE1 + 9 numbers

Regex would be: /^(BE)([0-1]{1}\d{9})$/

Making the following valid: BE0838713666 BE0838713666 BE1838713666

And making the following invalid: 0838713666 0838713666 1838713666

And we leave it to the developers to add it before validating if they would like to validate only numbers of vat: For example: checkVat('BE' + userInput, ...)

This would also mean we don't need to change the input nor alert that an input has changed. But I'm open for discussing this, what is your current use-case?

mattickx commented 10 months ago

Like previously mentioned, I've changed Belgium such that the format becomes: BE + Prefix (0 or 1) + 9 numbers

"BE" prefix currently needs to be present, but can be changed if that is a use case that is needed. I've added 3 lines for this in commentary with the notice: "BE: Optional Country Code".

Validating without BE could be achieved by: checkVat('BE' + userInput, ...)

satblip commented 10 months ago

A Belgian company number without BE is indeed a valid KBO number (local company registry), but not a correct VAT number that will need the prefix to be present

mattickx commented 9 months ago

I'm closing this issue for now, feel free to comment if the community has other concerns about this specific case