taxidentificationnumber

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package taxidentificationnumber provides parsing and validation for German Tax Identification Numbers (Steuerliche Identifikationsnummer).

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLength = errors.New("tax identification number: must be 11 digits long")
	ErrSyntax = errors.New("tax identification number: must only contain digits, and may not start with 0")
	// ErrRepetition signifies that the parser found a number that appears
	// more than three times, or that it found two numbers that appear
	// more than once.
	ErrRepetition = errors.New("tax identification number: mustn't contain the same digit more than three times")
	ErrCheckDigit = errors.New("tax identification number: invalid check digit")
)

Functions

func IsValid

func IsValid(s string) bool

IsValid validates that s represents a syntactically valid German tax id.

Spaces are ignored.

func IsValidNum

func IsValidNum(n uint64) bool

IsValidNum is the same as IsValid, but takes a number instead of a string.

Types

type TaxIdentificationNumber

type TaxIdentificationNumber uint64

TaxIdentificationNumber is a German Tax Identification Number (Steuerliche Identifikationsnummer).

It does not contain any spaces.

func Parse

Parse parses the passed German tax id.

Spaces and '/' are ignored.

If Parse returns without an error, the tax id is considered syntactically valid.

func ParseNum

func ParseNum(n uint64) (TaxIdentificationNumber, error)

ParseNum is the same as Parse, but takes a number instead of a string.

func (TaxIdentificationNumber) Compact

func (id TaxIdentificationNumber) Compact() string

func (TaxIdentificationNumber) MarshalText

func (id TaxIdentificationNumber) MarshalText() ([]byte, error)

func (TaxIdentificationNumber) String

func (id TaxIdentificationNumber) String() string

String returns a human-readable representation of the tax ID, by separating the tax ID into its parts.

The returned string is in the format "XX XXX XXX XXX".

If the TaxIdentificationNumber is invalid, it is returned as is.

It is guaranteed that for any valid TaxIdentificationNumber, the returned string can be parsed back into the same TaxIdentificationNumber.

func (*TaxIdentificationNumber) UnmarshalText

func (id *TaxIdentificationNumber) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL