Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validating an empty string as a VAT no. returns true #1010

Closed
Luke1982 opened this issue Mar 11, 2021 · 4 comments
Closed

Validating an empty string as a VAT no. returns true #1010

Luke1982 opened this issue Mar 11, 2021 · 4 comments
Assignees
Labels

Comments

@Luke1982
Copy link
Contributor

if ($num_tva=='') {
return true;
}

I think this is fundamentally wrong. We essentially say that an empty string is a valid EU VAT no., which it most definitely is not.

@joebordes
Copy link
Contributor

I think this was totally on purpose to support creating accounts without a VAT number but forcing a valid one if given. That is a very typical use case when you are still prospecting.
If you don't want to support that make the field mandatory and it should work.
Open the issue again if I'm wrong.

@Luke1982
Copy link
Contributor Author

You're not wrong, but I do think we're taking a wrong approach. I wanted to re-use this function in a module I created to see if the VAT no. was correct. But I had to manually re-check the field for presence of any string at all. I think the functionality should be split over two logical functions:

  • Validate a VAT no. That does not accept an empty string. This is solely used to take a VAT no. and to see if it is valid.
  • Validate the VAT field, which should allow an empty string (since yes, there are sales stages in which this could occur) but if the field is not empty, it should be a valid VAT no.

@Luke1982 Luke1982 reopened this Mar 12, 2021
@joebordes
Copy link
Contributor

that sounds reasonable to me. go ahead I will accept it

@reetp
Copy link
Contributor

reetp commented Mar 18, 2021

* Validate the VAT field, which **should** allow an empty string (since yes, there are sales stages in which this could occur) but if the field is not empty, it should be a valid VAT no.

Absolutely.

We have LOTS of clients who do not have a VAT number. Enforcing this would be dire for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants