Help us shape the future of Go! Take the 2026 Go Developer Survey

mimir

package module
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2019 License: MIT Imports: 4 Imported by: 0

README

Mimir  Build Status Go Report Card GoDoc

What is Mimir ?

Mimir is a lightweight library that exposes some functions to validate banking informations.

Disclaimer

This library is still in development, so it might be possible that some methods change over time.

Methods available

As the project just started, it is quite poor in methods.
Stay tuned for updates !

IBAN Methods
Method Name Short Description
IsIBANValid Validate an IBAN
GetIBANCheckDigits Compute or fix check digits from an IBAN
FormatIBAN Format IBAN based on its structure
PrintFormatIBAN Format IBAN as it would be printed
GetCountryConfiguration Get country configuration and informations
SplitIBAN Split the IBAN based on its structure
ABA Routing Number Methods
Method Name Short Description
IsABARTNValid Validate an ABA
GetABARTNCheckDigit Compute or fix check digits for an ABA
SplitABARTN Split the ABA based on its structure
Supported countries

Please visit SUPPORTED_COUNTRIES.md

Use

Get
$ go get -u github.com/vdlbk/mimir
Examples
Validate an IBAN
package main

import (
	"fmt"
	"github.com/vdlbk/mimir"
)

func main(){
	IBAN := "FR1420041010050500013M02606"
	
	err := mimir.IsIBANValid(IBAN)
	fmt.Println(err) // nil
	
	badIBAN := "FR1420041010050500013M02605"
	
	err = mimir.IsIBANValid(badIBAN)
	fmt.Println(err) // IBAN invalid checksum
}

Documentation

Index

Constants

View Source
const (
	// ErrIBANTooshort is the error when an IBAN is too short for the validation process
	ErrIBANTooshort = mimirError("IBAN is too short")

	// ErrIBANIncorrectLength is the error when a IBAN does not have the required length
	ErrIBANIncorrectLength = mimirError("IBAN incorrect length")

	// ErrIBANInvalidChecksum is the error when a IBAN is invalid
	ErrIBANInvalidChecksum = mimirError("IBAN invalid checksum")

	// ErrCountryCodeDoesNotExist is the error when you lookup for a country code that does not exists
	ErrCountryCodeDoesNotExist = mimirError("Country Code does not exist")

	// ErrABARTNInvalidLength is the error when an ABA Routing Number is too short the the validation process
	ErrABARTNInvalidLength = mimirError("ABA is too short. 9 digits is expected")

	// ErrABAInvalidChecksum is the error when a ABA Routing Number is invalid
	ErrABAInvalidChecksum = mimirError("ABA Routing Number invalid checksum")
)

Errors

View Source
const (
	AccountNumberIBANDigitKey                = "a" // alphanumeric
	NationalBankCodeIBANDigitKey             = "b" // numeric
	CountryCodeIBANDigitKey                  = "c" // alphabetic
	CheckIBANDigitKey                        = "k" // checksum
	NationalIdentificationNumberIBANDigitKey = "i"
	CurrencyIBANDigitKey                     = "m" // alphanumeric
	AccountHolderIBANDigitKey                = "n"
	ReserveNumberIBANDigitKey                = "o" // always 0
	BranchCodeIBANDigitKey                   = "s" // counter code
	AccountTypeIBANDigitKey                  = "t"
	SWIFTBICCodeIBANDigitKey                 = "w" // alphanumeric
	NationalCheckIBANDigitKey                = "x" // numeric
)

IBAN - Structure digit keys

View Source
const (
	FederalReserveRoutingSymbolABADigitKey = "f" // numeric
	ABAInstitutionIdentifierDigitKey       = "a" // numeric
	CheckABADigitKey                       = "k" // checksum // numeric
)

ABA Routing Number - Structure digit keys

Variables

This section is empty.

Functions

func FormatIBAN added in v0.5.0

func FormatIBAN(iban string) (string, error)

FormatIBAN formats the given IBAN with the different parts that are defined in its structure.

func GetABARTNCheckDigit added in v0.7.0

func GetABARTNCheckDigit(aba string) (string, string, error)

GetABARTNCheckDigit compute the check digits from a given ABA Routing Number. Returns the computed digit and the ABA updated with the check digits or an error if something goes wrong. The ABA must contains 9 digits but the last one will ignored. It's possible to use this function by adding an extra 0 at the end if the ABA is not a valid one.

func GetCountryConfiguration added in v0.1.1

func GetCountryConfiguration(countryCode string) (*configuration, error)

GetCountryConfiguration returns ISO 13616-Compliant IBAN Formats from a given country code If the countryCode does not exist in the list, returns an error `ErrCountryCodeDoesNotExist`

func GetIBANCheckDigits added in v0.6.0

func GetIBANCheckDigits(iban string) (string, string, error)

GetIBANCheckDigits compute the check digits from a given IBAN. Returns the computed digits, the IBAN set with the check digits or an error if something goes wrong.

func IsABARTNValid added in v0.7.0

func IsABARTNValid(aba string) error

IsABARTNValid checks if the given ABA Routing Number is valid.

func IsIBANValid

func IsIBANValid(iban string) error

IsIBANValid checks if the given IBAN is valid based on the country its belong to.

func PrintFormatIBAN added in v0.2.0

func PrintFormatIBAN(iban string) (string, error)

PrintFormatIBAN formats the given IBAN based on the regular way to print it depending the country. It will use the PrintFormat of the configuration to insure the result.

func SplitABARTN added in v0.7.0

func SplitABARTN(aba string) ([]string, []string, error)

SplitABARTN splits a given valid ABA Routing Number depending its structure. It returns a list of digit keys and a list that contains each part of the structure or an error if something went wrong.

func SplitIBAN added in v0.5.0

func SplitIBAN(iban string) ([]string, []string, error)

SplitIBAN splits a given IBAN depending the structure of its country. It returns a list of digit keys, a list that contains each part of the structure or an error if something went wrong.

Types

This section is empty.

Jump to

Keyboard shortcuts

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