-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework to add UK VAT validation and improve error reporting (#6)
* Rework to add UK VAT validation and improve error reporting * Few little tweaks * Appease the linter gods * I guess remove this blank import as it seems to be unnecessary * Few changes based on PR review * Remove ErrUnexpected since any error we don't handle is unexpected...
- Loading branch information
1 parent
cfdeb7b
commit 3963391
Showing
17 changed files
with
652 additions
and
566 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package vat | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
) | ||
|
||
// ErrInvalidVATNumberFormat will be returned if a VAT with an invalid format is given | ||
var ErrInvalidVATNumberFormat = errors.New("vat: VAT number format is invalid") | ||
|
||
// ErrVATNumberNotFound will be returned if the given VAT number is not found in the external lookup service | ||
var ErrVATNumberNotFound = errors.New("vat: number not found as an existing active VAT number") | ||
|
||
// ErrInvalidCountryCode indicates that this package could not find a country matching the VAT number prefix | ||
var ErrInvalidCountryCode = errors.New("vat: unknown country code") | ||
|
||
// ErrInvalidRateLevel will be returned when getting wrong rate level | ||
var ErrInvalidRateLevel = errors.New("vat: unknown rate level") | ||
|
||
// ErrServiceUnavailable will be returned when the service is unreachable | ||
type ErrServiceUnavailable struct { | ||
Err error | ||
} | ||
|
||
// Error returns the error message | ||
func (e ErrServiceUnavailable) Error() string { | ||
return fmt.Sprintf("vat: service is unreachable: %v", e.Err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
//go:generate mockgen -destination=mocks/mock_lookup_service.go -package=mocks github.com/teamwork/vat/v3 LookupServiceInterface | ||
|
||
package vat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module github.com/teamwork/vat/v2 | ||
module github.com/teamwork/vat/v3 | ||
|
||
go 1.21 | ||
|
||
|
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.