/iban4j2JavApi

A Swift library for generation and validation of the International Bank Account Numbers (IBAN ISO_13616) and Business Identifier Codes (BIC ISO_9362).

Primary LanguageSwiftApache License 2.0Apache-2.0

iban4j2JavApi

License

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.

Iban quick examples:

  // 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
    }

Bic quick examples:

  // 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
  }

Enable left padding examples:

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

References

Note

Versions later than 3.9 are not call compatible with iban4j.

Thanks to

License

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