iban4j icon indicating copy to clipboard operation
iban4j copied to clipboard

Builder fails for cz accounts

Open PavelNiedoba opened this issue 6 years ago • 1 comments

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)

PavelNiedoba avatar Apr 11 '18 21:04 PavelNiedoba

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

bvaardal avatar Jun 28 '20 02:06 bvaardal

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();

hajk1 avatar Aug 29 '23 07:08 hajk1

Thats nice!

PavelNiedoba avatar Aug 31 '23 13:08 PavelNiedoba