本文整理匯總了Golang中github.com/AntoineAugusti/moduluschecking/models.BankAccount.SortCode方法的典型用法代碼示例。如果您正苦於以下問題:Golang BankAccount.SortCode方法的具體用法?Golang BankAccount.SortCode怎麽用?Golang BankAccount.SortCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/AntoineAugusti/moduluschecking/models.BankAccount
的用法示例。
在下文中一共展示了BankAccount.SortCode方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: IsValid
// Tell if the bank account is valid
func (e Exception5Checker) IsValid(b m.BankAccount, sc m.SortCodeData, attempt int) bool {
if !e.Handles(b, sc, attempt) {
panic("Should be exception of type 5")
}
if substitution, hasKey := e.Substitutions[b.SortCode]; hasKey {
b.SortCode = substitution
}
// First attempt
if attempt == 1 {
checkDigit := b.NumberAtPosition("g")
remainder := GeneralChecker{}.RemainderFromRegularCheck(b, sc)
if remainder == 0 && checkDigit == 0 {
return true
}
if remainder == 1 {
return false
}
return (11 - remainder) == checkDigit
}
// Second attempt
checkDigit := b.NumberAtPosition("h")
remainder := GeneralChecker{}.RemainderFromRegularCheck(b, sc)
if remainder == 0 && checkDigit == 0 {
return true
}
return (10 - remainder) == checkDigit
}
示例2: IsValid
// 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)
}