postalcode

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: 3 Imported by: 0

Documentation

Overview

Package postalcode provides parsing and validation for German ZIP codes (Postleitzahl).

Index

Constants

This section is empty.

Variables

View Source
var ErrSyntax = errors.New("de/postalcode: postal codes must be 5-digit numbers")

Functions

func IsValid

func IsValid(s string) bool

IsValid returns true if the postal code is valid.

Types

type PostalCode

type PostalCode string

PostalCode represents a German postal code 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

Jump to

Keyboard shortcuts

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