models

package
v0.0.0-...-2d224b7 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2019 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BankAccount

type BankAccount struct {
	SortCode      string
	AccountNumber string
}

Represents a UK bank account

func CreateBankAccount

func CreateBankAccount(sortCode, accountNumber string) BankAccount

Create a BankAccount structure from a sort code and an account number

func (BankAccount) AccountNumberSlice

func (b BankAccount) AccountNumberSlice() []int

The account number has an integers slice

func (BankAccount) MergeAccountDetails

func (b BankAccount) MergeAccountDetails() []int

Merge the sort code and the account number of a bank account into a single slice

func (BankAccount) NumberAtPosition

func (b BankAccount) NumberAtPosition(letter string) int

NumberAtPosition gets the integer value from a letter, according to the defined code: Letters between u and z select a digit from the sort code Letters between a and h select a digit from the account number

func (BankAccount) SortCodeSlice

func (b BankAccount) SortCodeSlice() []int

The sort code has an integers slice

type Checker

type Checker interface {
	// Determine if the checker is able to validate the bank account
	Handles(b BankAccount, sc SortCodeData, attempt int) bool
	// Tell if the bank account is valid
	IsValid(b BankAccount, sc SortCodeData, attempt int) bool
}

A checker is in charge of validating a bank account number

type Checkers

type Checkers []Checker

type Parser

type Parser interface {
	// Read the weights, exception information and algorithm to use for sort code ranges.
	Weights() map[string]SortCodeData
	// Give a list of sort code substitutions
	Substitutions() map[string]string
}

A parser should be able to: - read the weights, exception information and algorithm to use for sort code ranges. - give a list of sort code substitutions.

type SortCodeData

type SortCodeData struct {
	// The algorithm to use:
	// - DBLAL: double alternate check
	// - MOD10: modulus with a modulus of 10
	// - MOD11: modulus with a modulus of 11
	Algorithm string
	// Weights to use for the sort code and the account number
	Weights []int
	// The exception value. If 0, the sort code does not have an exception.
	ExceptionValue int
	// If a sort code follows multiple rule, Next will not be nil.
	Next *SortCodeData
	// Indicates the line number where this rule was stored in the file.
	LineNumber int
}

Give information about a sort code

func (SortCodeData) FollowsExceptions

func (s SortCodeData) FollowsExceptions(ex1, ex2 int) bool

FollowsExceptions checks if a sort code follows 2 exceptions.

func (SortCodeData) HasException

func (s SortCodeData) HasException() bool

HasException Does this sort code has got an exception?

func (SortCodeData) HasNext

func (s SortCodeData) HasNext() bool

HasNext Does this sort code follows another rule?

func (SortCodeData) IsException

func (s SortCodeData) IsException(exceptionValue int) bool

IsException checks if a sort code follows an exception.

type SortCodeRange

type SortCodeRange struct {
	// Beginning of the sort code range.
	Start int
	// End of the sort code range.
	End int
	// The algorithm to use:
	// - DBLAL: double alternate check
	// - MOD10: modulus with a modulus of 10
	// - MOD11: modulus with a modulus of 11
	Algorithm string
	// Weights to use for the sort code and the account number
	Weights []int
	// The exception value. If 0, the sort code does not have an exception.
	ExceptionValue int
	// Indicates the line number where this rule was stored in the file.
	LineNumber int
}

This structure describes a sort code range, starting from a sort code and ending to another.

func (SortCodeRange) HasException

func (sc SortCodeRange) HasException() bool

HasException checks if a sort code range has got an exception

Jump to

Keyboard shortcuts

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