Skip to content

Commit 2a35151

Browse files
Merge pull request #14 from GeertJohan/patch-1
Export ErrCountryNotFound
2 parents 7af910a + cb1417a commit 2a35151

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

numbers.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff 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.
2626
var 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.
3033
func 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:])

0 commit comments

Comments
 (0)