Banking
Banking library
Install / Use
/learn @jacoelho/BankingREADME
Banking
Banking related library.
Install
go get -u github.com/jacoelho/banking
IBAN
Supports IBAN validation based on swift rules.
Usage
Validation
err := iban.Validate("SOME IBAN")
For simple validation error detection:
if iban.IsValidationError(err) {
// Handle validation errors
}
Error Handling
For detailed validation feedback, the library provides structured error types:
import "errors"
err := iban.Validate("GB99INVALID")
if err != nil {
var lengthErr *iban.ErrValidationLength
if errors.As(err, &lengthErr) {
fmt.Printf("Invalid length: expected %d, got %d\n", lengthErr.Expected, lengthErr.Actual)
}
var checksumErr *iban.ErrValidationChecksum
if errors.As(err, &checksumErr) {
fmt.Printf("Invalid checksum: expected %s, got %s\n", checksumErr.Expected, checksumErr.Actual)
}
var rangeErr *iban.ErrValidationRange
if errors.As(err, &rangeErr) {
fmt.Printf("Invalid characters at position %d (length %d): expected %s\n",
rangeErr.Position, rangeErr.Length, rangeErr.Expected)
}
var staticErr *iban.ErrValidationStaticValue
if errors.As(err, &staticErr) {
fmt.Printf("Invalid value at position %d: expected %s, got %s\n",
staticErr.Position, staticErr.Expected, staticErr.Actual)
}
var unsupportedErr *iban.ErrUnsupportedCountry
if errors.As(err, &unsupportedErr) {
fmt.Printf("Country code '%s' is not supported\n", unsupportedErr.CountryCode)
}
}
Replace check digits
result, err := iban.ReplaceChecksum("GB99NWBK60161331926819")
// Output: GB29NWBK60161331926819
Generation
iban, err := iban.Generate("GB")
// Output: GB29NWBK60161331926819
Printing
iban.PaperFormat("GB29NWBK60161331926819"))
// Output: GB29 NWBK 6016 1331 9268 19
BBAN
// Get BBAN from IBAN
result, _ := iban.GetBBAN("GB29NWBK60161331926819")
fmt.Println(result.BBAN, result.BankCode, result.BranchCode, result.AccountNumber)
// Output: NWBK60161331926819 NWBK 601613 31926819
IsSEPA
// IsSEPA returns if an iban country is a SEPA member
result, _ := iban.IsSEPA("GB29NWBK60161331926819")
fmt.Println(result)
// Output: true
ISO-7064
Mod-97-10 implemented.
Generate
To update the registry from a TSV file and regenerate IBAN validation code:
make update-registry REGISTRY=iban-registry-v101.txt
License
MIT License
See LICENSE to see the full text.
Related Skills
node-connect
352.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
352.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
