💾 Archived View for code.pfad.fr › swift captured on 2023-06-14 at 13:54:16. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-05-24)

➡️ Next capture (2023-07-10)

-=-=-=-=-=-=-

swift package

import "code.pfad.fr/swift"

package swift provides methods to check the validity of an IBAN (and to retrieve some BIC codes).

Example

package main

import (
	"fmt"

	"code.pfad.fr/swift"
	"code.pfad.fr/swift/bic"
)

var germanTestIBAN = "DE75512108001245126199"

func main() {
	iban, err := swift.ParseIBAN(germanTestIBAN)
	if err != nil {
		panic(err)
	}
	country := iban.CountryCode
	fmt.Println(country, country.BelongsToSEPA())

	fmt.Println("BIC:", bic.FromIBAN(iban))
}

Types

type CheckDigitsError

type CheckDigitsError struct {
	Expected      int
	Actual        int
	NationalCheck bool // true if the check failed at the country level (within the BBAN)
}

func (CheckDigitsError) Error

func (e CheckDigitsError) Error() string

type CountryCode

type CountryCode string

CountryCode is the ISO 3166-1 alpha-2 code of the country (uppercase)

func (CountryCode) BelongsToIBANRegistry

func (cc CountryCode) BelongsToIBANRegistry() bool

BelongsToIBANRegistry returns true if the country is listed in the iban registry [https://www.swift.com/resource/iban-registry-pdf] as of 2023-03-22

https://www.swift.com/resource/iban-registry-pdf

func (CountryCode) BelongsToSEPA

func (cc CountryCode) BelongsToSEPA() bool

BelongsToSEPA indicates if a country belongs to the Single Euro Payments Area, as of 2023-03-23 [https://en.wikipedia.org/wiki/Single_Euro_Payments_Area#Coverage]

https://en.wikipedia.org/wiki/Single_Euro_Payments_Area#Coverage

type FormatError

type FormatError struct {
	Position int
	Expected string
	Got      string

	Part         string
	PartPosition int
}

func (FormatError) Error

func (e FormatError) Error() string

type IBAN

type IBAN struct {
	CountryCode CountryCode
	CheckDigits int
	BBAN        string
}

func ParseIBAN

func ParseIBAN(s string) (IBAN, error)

ParseIBAN will parse an IBAN and perform some basic checks (overall length, check digit sum). If there is a registered BBANChecker for this country code, it will be run as well. If the country code is unknown, the IBAN will be accepted.

func (IBAN) MaskedAndSpaced

func (iban IBAN) MaskedAndSpaced() string

MaskedAndSpaced returns the IBAN, with only the first and last 3 chars of the BBAN as well as spaces every 4 characters.

func (IBAN) Spaced

func (iban IBAN) Spaced() string

Spaced returns the IBAN with spaces between every 4 characters.

func (IBAN) String

func (iban IBAN) String() string

String returns the IBAN, without spaces

type ToShortError

type ToShortError struct {
	Got      int
	Expected int
}

func (ToShortError) Error

func (e ToShortError) Error() string

Files

bban.go

bban_fr.go

bban_iso13616.go

columns.go

country.go

errors.go

iban.go

Directories

bic

format

Forge

https://codeberg.org/pfad.fr/swift

git clone

https://codeberg.org/pfad.fr/swift
git@codeberg.org:pfad.fr/swift