banking

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

README

banking

banking provides helpers for financial identifiers — IBAN, ISIN, LEI, and UTI parsing, validation, and formatting, plus GLEIF API lookup.

Types

Type Description
IBAN IBAN value object with validation
ISIN ISIN value object with Luhn checksum validation
LEI Legal Entity Identifier value object
UTI ISO 23897:2020 Unique Transaction Identifier value object
GLIEF Struct modelling the GLEIF API v1 LEI-records response

Functions

IBAN
Function Description
NewIBAN(iban string) (IBAN, error) Constructs and validates an IBAN
(*IBAN).String() string Returns the raw IBAN string
ISIN
Function Description
(*ISIN).IsValid() bool Validates checksum and country prefix
(*ISIN).String() string Returns the raw ISIN string
(*ISIN).Get() string Returns the ISIN value
(*ISIN).Set(string) error Sets and validates the ISIN
(*ISIN).Printable() string Returns human-formatted ISIN (e.g. GB 123456789 0)
LEI
Function Description
NewLEI(lei string) (LEI, error) Constructs and validates an LEI
(*LEI).Formatted() string Returns a segmented LEI (LOU, reserved, entity, checksum)
(*LEI).String() string Returns the raw LEI string
UTI
Function Description
NewISO23897UTI(generatingEntity string) (UTI, error) Generates an ISO 23897 UTI from a 20-char entity ID
(*UTI).String() string Returns the raw UTI string
(*UTI).Get() string Returns the UTI value
(*UTI).Set(string) error Sets and validates the UTI
(*UTI).IsValid() (bool, error) Validates UTI length (42–52 chars)
(*UTI).IsEmpty() bool Checks if the UTI is empty
(*UTI).Formatted() string Returns human-formatted UTI
GLEIF Lookup
Function Description
Lookup_LEI(inISIN string) (string, error) Looks up the LEI for an ISIN via the GLEIF API

Example

import "github.com/mt1976/frantic-core/banking"

func main() {
    iban, err := banking.NewIBAN("GB82WEST12345698765432")
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(iban.String())

    lei, err := banking.NewLEI("529900T8BM49AURSDO55")
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(lei.Formatted())
}

Documentation

Overview

Package banking provides helpers for financial identifiers and standards such as IBAN, ISIN, LEI, and UTI parsing and validation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Lookup_LEI

func Lookup_LEI(inISIN string) (string, error)

Types

type GLIEF

type GLIEF struct {
	Meta struct {
		GoldenCopy struct {
			PublishDate time.Time `json:"publishDate"`
		} `json:"goldenCopy"`
		Pagination struct {
			CurrentPage int `json:"currentPage"`
			PerPage     int `json:"perPage"`
			From        int `json:"from"`
			To          int `json:"to"`
			Total       int `json:"total"`
			LastPage    int `json:"lastPage"`
		} `json:"pagination"`
	} `json:"meta"`
	Links struct {
		First string `json:"first"`
		Last  string `json:"last"`
	} `json:"links"`
	Data []struct {
		Type       string `json:"type"`
		ID         string `json:"id"`
		Attributes struct {
			Lei    string `json:"lei"`
			Entity struct {
				LegalName struct {
					Name     string `json:"name"`
					Language string `json:"language"`
				} `json:"legalName"`
				OtherNames               []any `json:"otherNames"`
				TransliteratedOtherNames []any `json:"transliteratedOtherNames"`
				LegalAddress             struct {
					Language                    string   `json:"language"`
					AddressLines                []string `json:"addressLines"`
					AddressNumber               any      `json:"addressNumber"`
					AddressNumberWithinBuilding any      `json:"addressNumberWithinBuilding"`
					MailRouting                 any      `json:"mailRouting"`
					City                        string   `json:"city"`
					Region                      string   `json:"region"`
					Country                     string   `json:"country"`
					PostalCode                  string   `json:"postalCode"`
				} `json:"legalAddress"`
				HeadquartersAddress struct {
					Language                    string   `json:"language"`
					AddressLines                []string `json:"addressLines"`
					AddressNumber               any      `json:"addressNumber"`
					AddressNumberWithinBuilding any      `json:"addressNumberWithinBuilding"`
					MailRouting                 any      `json:"mailRouting"`
					City                        string   `json:"city"`
					Region                      string   `json:"region"`
					Country                     string   `json:"country"`
					PostalCode                  string   `json:"postalCode"`
				} `json:"headquartersAddress"`
				RegisteredAt struct {
					ID    string `json:"id"`
					Other any    `json:"other"`
				} `json:"registeredAt"`
				RegisteredAs any    `json:"registeredAs"`
				Jurisdiction string `json:"jurisdiction"`
				Category     any    `json:"category"`
				LegalForm    struct {
					ID    string `json:"id"`
					Other string `json:"other"`
				} `json:"legalForm"`
				AssociatedEntity struct {
					Lei  any `json:"lei"`
					Name any `json:"name"`
				} `json:"associatedEntity"`
				Status     string `json:"status"`
				Expiration struct {
					Date   any `json:"date"`
					Reason any `json:"reason"`
				} `json:"expiration"`
				SuccessorEntity struct {
					Lei  any `json:"lei"`
					Name any `json:"name"`
				} `json:"successorEntity"`
				OtherAddresses []any `json:"otherAddresses"`
			} `json:"entity"`
			Registration struct {
				InitialRegistrationDate time.Time `json:"initialRegistrationDate"`
				LastUpdateDate          time.Time `json:"lastUpdateDate"`
				Status                  string    `json:"status"`
				NextRenewalDate         time.Time `json:"nextRenewalDate"`
				ManagingLou             string    `json:"managingLou"`
				CorroborationLevel      string    `json:"corroborationLevel"`
				ValidatedAt             struct {
					ID    string `json:"id"`
					Other any    `json:"other"`
				} `json:"validatedAt"`
				ValidatedAs                any   `json:"validatedAs"`
				OtherValidationAuthorities []any `json:"otherValidationAuthorities"`
			} `json:"registration"`
			Bic any `json:"bic"`
		} `json:"attributes"`
		Relationships struct {
			ManagingLou struct {
				Links struct {
					Related string `json:"related"`
				} `json:"links"`
			} `json:"managing-lou"`
			LeiIssuer struct {
				Links struct {
					Related string `json:"related"`
				} `json:"links"`
			} `json:"lei-issuer"`
			FieldModifications struct {
				Links struct {
					Related string `json:"related"`
				} `json:"links"`
			} `json:"field-modifications"`
			DirectParent struct {
				Links struct {
					ReportingException string `json:"reporting-exception"`
				} `json:"links"`
			} `json:"direct-parent"`
			UltimateParent struct {
				Links struct {
					ReportingException string `json:"reporting-exception"`
				} `json:"links"`
			} `json:"ultimate-parent"`
			DirectChildren struct {
				Links struct {
					RelationshipRecords string `json:"relationship-records"`
					Related             string `json:"related"`
				} `json:"links"`
			} `json:"direct-children"`
			UltimateChildren struct {
				Links struct {
					RelationshipRecords string `json:"relationship-records"`
					Related             string `json:"related"`
				} `json:"links"`
			} `json:"ultimate-children"`
			Isins struct {
				Links struct {
					Related string `json:"related"`
				} `json:"links"`
			} `json:"isins"`
		} `json:"relationships"`
		Links struct {
			Self string `json:"self"`
		} `json:"links"`
	} `json:"data"`
}

type IBAN

type IBAN struct {
	// contains filtered or unexported fields
}

func NewIBAN

func NewIBAN(iban string) (IBAN, error)

func (*IBAN) String

func (I *IBAN) String() string

type ISIN

type ISIN struct {
	// contains filtered or unexported fields
}

func (*ISIN) Get

func (I *ISIN) Get() string

func (*ISIN) IsValid

func (I *ISIN) IsValid() bool

IsValid checks if the given ISIN is valid.

func (*ISIN) Printable

func (I *ISIN) Printable() string

func (*ISIN) Set

func (I *ISIN) Set(in string) error

func (*ISIN) String

func (I *ISIN) String() string

type LEI

type LEI struct {
	// contains filtered or unexported fields
}

func NewLEI

func NewLEI(lei string) (LEI, error)

func (*LEI) Formatted

func (l *LEI) Formatted() string

The function `Formatted` takes a Legal Entity Identifier (LEI) as input and returns a formatted string with the LEI divided into its components.

func (*LEI) String

func (L *LEI) String() string

type UTI

type UTI struct {
	// contains filtered or unexported fields
}

func NewISO23897UTI

func NewISO23897UTI(generatingEntity string) (UTI, error)

NewISO23897UTI generates an ISO 23897:2020 compliant Unique Transaction Identifier (UTI).

func (*UTI) Formatted

func (U *UTI) Formatted() string

func (*UTI) Get

func (U *UTI) Get() string

func (*UTI) IsEmpty

func (U *UTI) IsEmpty() bool

func (*UTI) IsValid

func (U *UTI) IsValid() (bool, error)

func (*UTI) Set

func (U *UTI) Set(in string) error

func (*UTI) String

func (U *UTI) String() string

Jump to

Keyboard shortcuts

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