tin

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLength = errors.New("de/tin: tax ids must be 11 digits long")
	ErrSyntax = errors.New("de/tin: tax ids 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("de/tin: tax ids may not contain the same digit more than three times")
	ErrCheckDigit = errors.New("de/tin: 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 TIN

type TIN uint64

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

It does not contain any spaces.

func Parse

func Parse(s string) (TIN, error)

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) (TIN, error)

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

func (TIN) Compact added in v0.5.0

func (id TIN) Compact() string

func (TIN) MarshalText

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

func (TIN) String

func (id TIN) 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 TIN is invalid, it is returned as is.

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

func (*TIN) UnmarshalText

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

Jump to

Keyboard shortcuts

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