Skip to content

Commit 782bf58

Browse files
authored
fix(iban): fix luhn algorithm implementation
Closes #4
1 parent 0641bdf commit 782bf58

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

iban/national_checksum.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,5 +336,5 @@ func luhn(s string) int {
336336
sum = (sum + n) % 10
337337
}
338338

339-
return 10 - sum%10
339+
return (10 - sum%10) % 10
340340
}

iban/parse_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func TestParse(t *testing.T) {
4848
{In: "EE44 3300 3384 0010 0007", Expect: "EE44 3300 3384 0010 0007"},
4949
{In: "FI21 1234 5600 0007 85", Expect: "FI21 1234 5600 0007 85"},
5050
{In: "FI14 1009 3000 1234 58", Expect: "FI14 1009 3000 1234 58"},
51+
{In: "FI32 9360 7346 0370 70", Expect: "FI32 9360 7346 0370 70"},
5152
{In: "FR14 2004 1010 0505 0001 3M02 606", Expect: "FR14 2004 1010 0505 0001 3M02 606"},
5253
{In: "FR76 3000 6000 0112 3456 7890 189", Expect: "FR76 3000 6000 0112 3456 7890 189"},
5354
{In: "HU42 1177 3016 1111 1018 0000 0000", Expect: "HU42 1177 3016 1111 1018 0000 0000"},

0 commit comments

Comments
 (0)