bic

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

Documentation

Overview

Package bic provides parsing and validation of BIC (ISO 9362) codes.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLength                   = errors.New("bic: invalid length")
	ErrCountryCodeInappropriate = errors.New("bic: country code is neither officially assigned nor user-assigned")
	ErrBusinessPartyPrefix      = errors.New("bic: invalid business party prefix")
	ErrBusinessPartySuffix      = errors.New("bic: invalid business party suffix")
	ErrBranchCode               = errors.New("bic: invalid branch code")
)

Functions

func IsValid

func IsValid(s string) bool

IsValid checks whether s is a syntactically correct BIC, as defined in Parse.

Types

type BIC

type BIC struct {
	// BusinessPartyPrefix, in former editions of ISO 9362 known as the
	// Bank or Institution Code, is a four-character alphanumeric code
	// that identifies the business party.
	BusinessPartyPrefix string
	// CountryCode is the two character alphabetic ISO 3166-1 alpha-2
	// country code.
	//
	// Besides the officially assigned ISO 3166-1 country codes, "XK" is used
	// to represent the Republic of Kosovo.
	CountryCode string
	// BusinessPartySuffix, in former editions of ISO 9362 known as the
	// Location Code, is a two-character alphanumeric code that identifies
	// the location of the business party.
	BusinessPartySuffix string
	// BranchCode is the three character optional alphanumeric branch code.
	//
	// Some BICs may use "XXX" as branch code, which is equivalent to an empty
	// branch code and denotes the primary office of the institution.
	BranchCode string
}

BIC is a ISO 9362 Business Identifier Code.

func Parse

func Parse(s string) (BIC, error)

Parse parses s into a BIC.

If Parse returns without an error, the BIC is considered syntactically correct.

Validation Notes

Despite not formally allowed by ISO 9362, Parse allows spaces and lowercase letters in s. The individual parts of the returned BIC are always uppercase and contain no spaces.

While SWIFT has, and will for the foreseeable future, only assigned letters to the business party prefix (c.f. 1: Entity Identifiers/BIC Structure and 2: section 4.3), ISO 9362 expressly allows digits in the business party prefix. Therefore, Parse DOES allow digits in the business party prefix.

func (*BIC) Compact added in v0.5.0

func (bic *BIC) Compact() string

func (BIC) MarshalText

func (bic BIC) MarshalText() ([]byte, error)

func (BIC) String

func (bic BIC) String() string

func (*BIC) UnmarshalText

func (bic *BIC) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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