Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when composing IBANs where the check digits have a leading zero #92

Closed
trustlydaniel opened this issue May 10, 2023 · 1 comment · Fixed by #93
Closed

Exception when composing IBANs where the check digits have a leading zero #92

trustlydaniel opened this issue May 10, 2023 · 1 comment · Fixed by #93
Assignees

Comments

@trustlydaniel
Copy link
Contributor

Check digits can have leading zeroes, Modulo97#calculateCheckDigits returns an int so the value needs to be left padded if size is less than two.

Example (IBAN in example is generated, not a real bank account):

public class CheckDigitsLeadingZeroExample {

  public static void main(String[] args) {
    String bban = "50516227620311";
    IBAN iban = IBAN.compose("DK", bban);
    //Expected iban: DK0350516227620311
    //throws: Input failed length validation: found 17, but expect 18 for country code.

    String input = "DK0050516227620311";
    int checkDigits = Modulo97.calculateCheckDigits(input);
    // checkDigits is 3
  }

}
@barend
Copy link
Owner

barend commented May 18, 2023

Hi @trustlydaniel,

Thanks! That's a good catch. The error is quite glaring once you see it, but I have missed it all these years 😬

Thanks also for providing #93 to fix it. Much appreciated.

Cheers,
Barend

@barend barend self-assigned this May 18, 2023
@barend barend closed this as completed in 1e827ad May 18, 2023
barend added a commit that referenced this issue May 18, 2023
barend added a commit that referenced this issue May 18, 2023
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 a pull request may close this issue.

2 participants