Documentation ¶
Overview ¶
Package iban provides parsing and validation for International Bank Account Numbers (IBAN).
It can validate the country code, checksum, and country-specific length and checksum (if the country has one).
For countries for which no information is available, it only validates the country code and checksum.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrLength = errors.New("iban: an iban must be at least 5 and at most 34 characters long") ErrCountryCode = errors.New("iban: invalid country code") ErrChecksum = errors.New("iban: checksum does not match") ErrCountrySpecific = errors.New("iban: bban does not match country-specific rules") ErrNationalChecksum = errors.New("iban: national checksum does not match") ErrBBAN = errors.New("iban: bban must consist of only letters and digits") )
Functions ¶
Types ¶
type IBAN ¶
type IBAN struct { // CountryCode is the ISO 3166-1 alpha-2 country code of the IBAN. CountryCode iso3166.Alpha2Code // Checksum is the checksum of the IBAN. Checksum uint8 // BBAN is the Basic Bank Account Number of the IBAN. BBAN string BankCode string BranchCode string AccountType string OwnerAccountNumber string OwnerIdentificationNumber string // e.g. kennitala in Iceland BalanceAccountNumber string AccountNumberPrefix string AccountNumber string NationalChecksum string CurrencyCode string }
IBAN represents an International Bank Account Number.
func Parse ¶
Parse parses the passed IBAN.
Spaces are ignored and input is treated as case-insensitive, however, the returned IBAN will always be uppercase.
Validation ¶
If Parse returns without an error, the IBAN is considered syntactically valid.
This means that the country code is valid, the checksum is correct, and the IBAN does not exceed the 34-character limit.
If country-specific rules are available, Parse will also validate the country-specific length of the IBAN, the correct format (i.e. ensure that numeric parts only contain digits, and alphabetic parts only contain letters), and the national checksum, if there is one. See IBAN formats by country for the rules employed by Parse.
func (IBAN) MarshalText ¶
func (IBAN) String ¶
String pretty-prints the IBAn by inserting spaces after every 4 characters.
If len(IBAN)%4 != 0, then the last group will be shorter than 4 characters.