コード例 #1
0
// Tell if the bank account is valid
func (e Exception2Checker) IsValid(b m.BankAccount, sc m.SortCodeData, attempt int) bool {
	if !e.Handles(b, sc, attempt) {
		panic("Should be exception of type 2")
	}

	sc.Weights = WeightsForException2Or9(b, sc)

	return GeneralChecker{}.IsValid(b, sc, attempt)
}
コード例 #2
0
// Tell if the bank account is valid
func (e Exception10Checker) IsValid(b m.BankAccount, sc m.SortCodeData, attempt int) bool {
	if !e.Handles(b, sc, attempt) {
		panic("Should be exception of type 10")
	}

	// Put 8 zeros at the beginning of the weights
	// and keep the original weights after
	zeros := []int{0, 0, 0, 0, 0, 0, 0, 0}
	sc.Weights = append(zeros, sc.Weights[8:]...)

	return GeneralChecker{}.IsValid(b, sc, attempt)
}
コード例 #3
0
// Tell if the bank account is valid
func (e Exception9Checker) IsValid(b m.BankAccount, sc m.SortCodeData, attempt int) bool {
	if !e.Handles(b, sc, attempt) {
		panic("Should be exception of type 9")
	}

	sc.Weights = WeightsForException2Or9(b, sc)
	if (GeneralChecker{}.IsValid(b, sc, attempt)) {
		return true
	}

	// Try to replace the sort code
	b.SortCode = "309634"

	return GeneralChecker{}.IsValid(b, e.Weights[b.SortCode], attempt)
}