arturmkrtchyan / iban4j

A Java library for generation and validation of the International Bank Account Numbers (IBAN ISO_13616) and Business Identifier Codes (BIC ISO_9362).
http://iban4j.org
Apache License 2.0
271 stars 124 forks source link

Builder fails for cz accounts #49

Closed PavelNiedoba closed 1 year ago

PavelNiedoba commented 6 years ago

new Iban.Builder().countryCode(CountryCode.CZ).bankCode("2010").accountNumber("2300121591").build().toString(); should be smart enough to work without leading zeroes for accountNumber

fails with org.iban4j.IbanFormatException: [20102300121591] length is 14, expected BBAN length is: 20 at org.iban4j.IbanUtil.validateBbanLength(IbanUtil.java:362) at org.iban4j.IbanUtil.validate(IbanUtil.java:79) at org.iban4j.Iban$Builder.build(Iban.java:365) at org.iban4j.Iban$Builder.build(Iban.java:337)

bvaardal commented 4 years ago

Although your accountNumber parameter is likely correct, this library expects 16 digits, i.e. the 10-digit account number appended to the 6-digit code as shown in the IBAN registry. Unfortunately, the IBAN registry does not indicate what those six digits are, although the "Domestic account number example" gives some indication (19 with pre-filled zeros).

Screen Shot 2020-06-27 at 9 58 14 PM

hajk1 commented 1 year ago

This issue is resolved as of version "3.2.5-RELEASE" by using setPadding(true) on the builder method:


new Iban.Builder()
        .leftPadding(true)
        .countryCode(CountryCode.CZ)
        .bankCode("2010")
        .accountNumber("2300121591")
        .build()
        .toString();
PavelNiedoba commented 1 year ago

Thats nice!