Documentation ¶
Overview ¶
Package postalcode provides parsing and validation for German postal codes (Postleitzahl).
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrSyntax = errors.New("postal code: must be 5-digit number")
Functions ¶
Types ¶
type PostalCode ¶
type PostalCode string
PostalCode represents a German postal code (Postleitzahl).
It is a 5-digit string.
func Parse ¶
func Parse(s string) (PostalCode, error)
Parse parses the passed postal code.
If Parse returns without an error, the postal code is considered syntactically valid.
Note that while checking if the postal code actually exists is possible, it is also error-prone, because as soon as a new postal code is assigned, or one is removed, the validation automatically becomes incorrect. Therefore, this package only checks for syntactical validity.
func (PostalCode) Compact ¶ added in v0.5.0
func (c PostalCode) Compact() string
func (PostalCode) MarshalText ¶
func (c PostalCode) MarshalText() ([]byte, error)
func (PostalCode) String ¶
func (c PostalCode) String() string
func (*PostalCode) UnmarshalText ¶
func (c *PostalCode) UnmarshalText(text []byte) error
Click to show internal directories.
Click to hide internal directories.