taxjar / vat_check

Validate EU VAT numbers the easy way with VIES!
23 stars 16 forks source link

If VIES service is unavailable, but the vat nr matches the regexp, it should not return "valid" #1

Closed franklouwers closed 7 years ago

franklouwers commented 7 years ago

On line 14 of file https://github.com/taxjar/vat_check/blob/master/lib/vat_check.rb#L14, you return true if the VAT number passes the regexp check, but the VIES service is not working for some reason. I don't think this should be the default. At worst, it should be configurable: we need to be sure the VAT number is correct. The reliability of the VIES services is often quite bad, but we need to be sure that a VAT number is a valid VAT number for accounting/reporting reasons.

jeroenj commented 7 years ago

We currently worked around it by using @vat_check.valid? && @vat_check.exists? but one would indeed expect valid? to return false if the VIES services are not working...

fastdivision commented 7 years ago

@franklouwers Since the VIES service is unreliable as mentioned, we wanted the valid? method to provide a graceful fallback to regex validation and our documentation reflects that. @jeroenj That's the right approach if you want to perform validation strictly around VIES. If you'd like to simplify it further, I'd create a tiny helper method in your own codebase to handle @vat_check.valid? && @vat_check.exists?.

I appreciate the feedback, but we want to support both VIES and regex validation at this time regardless of the semantics around the valid? method name when VIES is unavailable. Thank you!