corfin

package module
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

README

Corporate Finance Go module cmdscale.com/corfin

CmdScale Project Go Reference CI Status Go Report Card

ISIN Validation

Ensures that the check-digit of a given International Securities Identification Numbers (ISIN) is correct:

package main

import "fmt"
import "cmdscale.com/corfin"

func main() {
	isin, err := corfin.NewISIN("DE000BAY0017") // non alphanumeric characters will be ignored
	if err != nil {
		fmt.Println(err) // isin is invalid
	}
	fmt.Println("ISIN is well-formed", isin.String())
}

Installation

go get cmdscale.com/corfin

License

BSD 3-Clause "New" or "Revised" License

Documentation

Overview

package corfin provides methods to check the validity of an International Securities Identification Number (ISIN)

Example
package main

import (
	"fmt"

	"cmdscale.com/corfin"
)

func main() {
	isin, err := corfin.NewISIN("DE000BAY0017") // non alphanumeric characters will be removed
	if err != nil {
		panic(err)
	}
	fmt.Println("ISIN:", isin.String())
}
Output:

ISIN: DE000BAY0017

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckDigitError

type CheckDigitError struct {
	Given    int
	Computed int
}

CheckDigitError indicates that the checksum did not match the expected check digit.

func (CheckDigitError) Error

func (e CheckDigitError) Error() string

type CountryCode

type CountryCode string

CountryCode is the ISO 3166-1 alpha-2 code of the country (uppercase)

type ISIN

type ISIN struct {
	CountryCode CountryCode
	// National Securities Identifying Number
	NSIN       string
	CheckDigit int
}

ISIN represents an International Securities Identification Number

func NewISIN

func NewISIN(s string, additionalRules ...ISINValidator) (ISIN, error)

NewISIN sanitizes, parses and checks an ISIN (length, check digit).

func (ISIN) String

func (isin ISIN) String() string

String returns the ISIN

type ISINValidator

type ISINValidator func(ISIN) error

ISINValidator makes additional checks on a given ISIN.

type LenError

type LenError int

LenError indicates that the provided ISIN is of the wrong length

func (LenError) Error

func (e LenError) Error() string

Jump to

Keyboard shortcuts

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