A Go library for working with Legal Entity Identifiers (LEIs) as defined in ISO 17442-1:2020
This library is a port of the leim Rust library developed by 21 Analytics.
import "github.com/trisacrypto/lei"
func main() {
// Check that a string is a valid LEI
err := lei.LEI("2594007XIACKNMUAW223").Check()
// err == nil
// Parse invalid LEIs to return error information
err = lei.LEI("2594007XIACKNMUAW222").Check()
// errors.Is(err, lei.ErrInvalidChecksum) == true
err = lei.LEI("25947XCKNMUAW223").Check()
// errors.Is(err, lei.ErrInvalidLength) == true
err = lei.LEI("2594007X#ACKNMUAW223").Check()
// errors.Is(err, lei.ErrInvalidChar) == true
// Check that a RegistrationAuthority is valid
err = lei.CheckRA("RA777777")
// err == nil
// Lookup an unknown RegistrationAuthority
err = lei.CheckRA("RA009099")
// errors.Is(err, lei.ErrUnknownRA) == true
}
Add the lei
dependency to your go.mod
:
$ go get github.com/trisacrypto/lei
This project is licensed under the MIT license to match the license of the upstream Rust library this package was ported from.