File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,9 @@ const serviceURL = "http://ec.europa.eu/taxation_customs/vies/services/checkVatS
2525// ErrInvalidVATNumber will be returned when an invalid VAT number is passed to a function that validates existence.
2626var ErrInvalidVATNumber = errors .New ("vat: vat number is invalid" )
2727
28+ // ErrCountryNotFound indicates that this package could not find a country matching the VAT number prefix.
29+ var ErrCountryNotFound = errors .New ("vat: country not found" )
30+
2831// ValidateNumber validates a VAT number by both format and existence.
2932// The existence check uses the VIES VAT validation SOAP API and will only run when format validation passes.
3033func ValidateNumber (n string ) (bool , error ) {
@@ -77,10 +80,9 @@ func ValidateNumberFormat(n string) (bool, error) {
7780 }
7881
7982 n = strings .ToUpper (n )
80- var CountryNotFound = errors .New ("CountryNotFound" )
8183 pattern , ok := patterns [n [0 :2 ]]
8284 if ! ok {
83- return false , CountryNotFound
85+ return false , ErrCountryNotFound
8486 }
8587
8688 matched , err := regexp .MatchString (pattern , n [2 :])
You can’t perform that action at this time.
0 commit comments