class Faker::Bank
def iban(legacy_country_code = NOT_GIVEN, country_code: 'GB')
def iban(legacy_country_code = NOT_GIVEN, country_code: 'GB') # Each country has it's own format for bank accounts # Many of them use letters in certain parts of the account # Using regex patterns we can create virtually any type of bank account warn_for_deprecated_arguments do |keywords| keywords << :country_code if legacy_country_code != NOT_GIVEN end begin pattern = fetch("bank.iban_details.#{country_code.downcase}.bban_pattern") rescue I18n::MissingTranslationData raise ArgumentError, "Could not find iban details for #{country_code}" end # Use Faker::Base.regexify for creating a sample from bank account format regex account = Base.regexify(/#{pattern}/) # Add country code and checksum to the generated account to form valid IBAN country_code.upcase + iban_checksum(country_code, account) + account end