iban

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrValidation = errors.New("validation error")

ErrValidation represents an IBAN validation error

Functions

func Generate added in v1.1.5

func Generate(countryCode string) (string, error)

Generate IBAN based on ISO 3166-1 country code

Example
package main

import (
	"fmt"
	"github.com/jacoelho/banking/iban"
)

func main() {
	// Validate an iban using country specific validate function
	result, _ := iban.Generate("GB")

	fmt.Println(result)
}
Output:

func IsSEPA added in v1.1.34

func IsSEPA(iban string) (bool, error)

IsSEPA returns if an iban country is a SEPA member

Example
package main

import (
	"fmt"
	"github.com/jacoelho/banking/iban"
)

func main() {
	// IsSEPA returns if an iban country is a SEPA member
	result, _ := iban.IsSEPA("GB29NWBK60161331926819")
	fmt.Println(result)
}
Output:

true

func IsSEPACountryCode added in v1.1.34

func IsSEPACountryCode(countryCode string) (bool, error)

IsSEPACountryCode returns if a country code is a SEPA member

Example
package main

import (
	"fmt"
	"github.com/jacoelho/banking/iban"
)

func main() {
	// IsSEPACountry returns if a country is a SEPA member
	result, _ := iban.IsSEPACountryCode("AE")
	fmt.Println(result)
}
Output:

false

func PaperFormat added in v1.1.10

func PaperFormat(iban string) string

PaperFormat returns iban in paper format Follows EBS 204 - 5 IBAN Format 2) Paper Format

Example
package main

import (
	"fmt"
	"github.com/jacoelho/banking/iban"
)

func main() {
	// Pretty print an iban
	fmt.Println(iban.PaperFormat("GB29NWBK60161331926819"))
}
Output:

GB29 NWBK 6016 1331 9268 19

func ReplaceChecksum added in v1.1.5

func ReplaceChecksum(iban string) (string, error)

ReplaceChecksum returns input iban with the correct check digits

Example
package main

import (
	"fmt"
	"github.com/jacoelho/banking/iban"
)

func main() {
	// Replace an iban checksum
	result, _ := iban.ReplaceChecksum("GB99NWBK60161331926819")

	fmt.Println(result)
}
Output:

GB29NWBK60161331926819

func Validate added in v1.1.3

func Validate(iban string) error

Validate an IBAN

Example
package main

import (
	"fmt"
	"github.com/jacoelho/banking/iban"
)

func main() {
	// Validate an iban
	fmt.Println(iban.Validate("VG96VPVG0000012345678901") == nil)
}
Output:

true

Types

type BBAN added in v1.1.9

type BBAN struct {
	BBAN             string
	BankCode         string
	BranchCode       string
	NationalChecksum string
	AccountNumber    string
}

BBAN is short for Basic Bank Account Number It represents a country-specific bank account number.

func GetBBAN added in v1.1.9

func GetBBAN(iban string) (BBAN, error)

GetBBAN retrieves BBAN from an iban

Example
package main

import (
	"fmt"
	"github.com/jacoelho/banking/iban"
)

func main() {
	// Get BBAN from IBAN
	result, _ := iban.GetBBAN("GB29NWBK60161331926819")

	fmt.Println(result.BBAN, result.BankCode, result.BranchCode, result.AccountNumber)
}
Output:

NWBK60161331926819 NWBK 601613 31926819

Source Files

Jump to

Keyboard shortcuts

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