Skip to content

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

Description

@trustlydaniel

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
  }

}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions