A Swift library for generation and validation of the International Bank Account Numbers (IBAN ISO_13616) and Business Identifier Codes (BIC ISO_9362) based on great projekt iban4j.
// How to generate Iban
do {
let iban = try org.iban4j.Builder()
.setCountryCode(org.iban4j.CountryCode.AT())
.setBankCode("19043")
.setAccountNumber("00234573201")
.build();
}
// How to create Iban object from String
let iban = IBAN(from: "DE89370400440532013000")
// How to create Iban object from formatted String
let iban = IBAN(from: "DE89 3704 0044 0532 0130 00");
// How to generate random Iban
do {
try Iban.random(org.iban4j.CountryCode.AT())
try Iban.random()
try org.iban4j.Builder()
.setCountryCode(org.iban4j.CountryCode.AT())
.setBankCode("19043")
.buildRandom()
}
// How to validate Iban
if let _ = IBAN(from: "DE89370400440532013000", withValidation: true),
let _ = IBAN(from: "DE89 3704 0044 0532 0130 00", withValidation: true){
// valid
}
else {
// invalid
}
// How to create Bic object from String
let bic = try Bic.valueOf("DEUTDEFF");
// How to validate Bic
do {
try BicUtil.validate("DEUTDEFF500");
// valid
} catch {
// invalid
}
// How to left pad('account number', 'bank code' and 'branch code') with zero
let iban1 = try org.iban4j.Builder()
.leftPadding(true)
.setCountryCode(CountryCode.DE())
.setBankCode("66280099")
.setAccountNumber("123456700")
.build();
// How to change default padding character ('0') with other
let iban2 = try org.iban4j.Builder()
.leftPadding(true)
.paddingCharacter("1")
.setCountryCode(CountryCode.DE())
.setBankCode("66280099")
.setAccountNumber("123456700")
.build();
- http://en.wikipedia.org/wiki/ISO_13616
- http://en.wikipedia.org/wiki/ISO_9362
- https://www.ecb.europa.eu/paym/retpaym/paymint/sepa/shared/pdf/iban_registry.pdf
Versions later than 3.9 are not call compatible with iban4j.
- Artur Mkrtchyan iban4j
Java iban4j is copyright 2015 Artur Mkrtchyan. Ported to Swift by Sebastian Ritter.
Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0