Skip to content

Reject IBAN check digits 00, 01 and 99 [patch] - #439

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/438-iban-check-digit-range
Oct 18, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/438-iban-check-digit-range

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #438

Summary

  • IsIbanAttribute now rejects check digits outside 02–98 before running the mod-97 test, with the message "The value must be a valid IBAN (check digits must be 02-98)."
  • ISO 13616 computes check digits as 98 - (n mod 97), so 00, 01 and 99 never occur. They are congruent to 97, 98 and 02, so the remainder test alone accepted them.

Tests

  • Create_CheckDigitsAtEdgeOfRange_Succeeds: GB98…, GB97…, GB02WEST00000000000029 still validate.
  • Create_CheckDigitsNeverIssued_Throws: GB01WEST12340000000012, GB00WEST12340000000030, GB99WEST00000000000029 throw, and the message names the check digits.
  • With the validator change reverted, all three rejection cases fail (no exception thrown). With it in place, the full Semantics.Test suite passes (1697 passed, 8 skipped).

Generated by Claude Code

ISO 13616 issues check digits as 98 - (n mod 97), so only 02-98 occur.
00, 01 and 99 are congruent to 97, 98 and 02 modulo 97, so the mod-97
test alone accepted an invalid twin of every IBAN with those digits.

Fixes #438

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016AQEMQSRnmweax4URvCpi3
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 42e3e65 into main Oct 18, 2026
16 checks passed
@matt-edmondson
matt-edmondson deleted the fix/438-iban-check-digit-range branch October 18, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Iban accepts check digits 00, 01 and 99, which ISO 13616 never issues: "GB01WEST12340000000012" and "GB00WEST12340000000030" validate

2 participants