composeIBAN function
composeIBAN
// returns `NL91ABNA0417164300`
ibantools.composeIBAN({ countryCode: "NL", bban: "ABNA0417164300" });
Implementation
String? composeIBAN(ComposeIBANParams params) {
final String? formattedBban = electronicFormatIBAN(params.bban);
if (params.countryCode == null || params.countryCode!.isEmpty) {
return null;
}
final CountrySpec? spec = countrySpecs[params.countryCode];
if (formattedBban != null &&
formattedBban.isNotEmpty &&
spec != null &&
spec.chars != null &&
spec.chars == formattedBban.length + 4 &&
spec.bbanRegexp != null &&
_checkFormatBBAN(formattedBban, spec.bbanRegexp!)) {
final int checksum = mod9710Iban('${params.countryCode!}00$formattedBban');
return '${params.countryCode!}${('0${(98 - checksum)}').substring(-2)}$formattedBban';
}
return null;
}