class

CrystalIBAN::Generator

Inherits Reference < Object

Generates valid IBAN strings for supported countries.

Constructors

new

Creates a generator pre-loaded with the bundled 49-country IBAN structures. This is the standard constructor for shard consumers.

gen = CrystalIBAN::Generator.new
gen.generate(country_code: "LI", bank_code: "08810", account_number: 6_188_284_i64)
# => "LI05088106188284"
Source
new(*, registry : StructureRegistry)

Creates a generator using a shared StructureRegistry. Use this when you also have a Validator to avoid parsing the JSON twice.

Source
new(*, json : String)

Creates a generator from a custom JSON string in the same format as iban_structure.json. Use this to extend or override the default country set.

custom_json = %([{"country":"Testland","country_code":"TS","iban_format":"CCXX BBBB AAAA"}])
gen = CrystalIBAN::Generator.new(json: custom_json)
Source

Class methods

generate(country_code : String, bank_code : String, account_number : Int64) : String

Generates a valid IBAN using the bundled default registry.

CrystalIBAN::Generator.generate(country_code: "LI", bank_code: "08810", account_number: 6_188_284_i64)
# => "LI05088106188284"
Source

Instance methods

generate(country_code : String, bank_code : String, account_number : Int64) : String

Generates a complete IBAN string for the given country and account details. Raises ArgumentError if the country code is not in the loaded structure file.

Source
valid?(iban : String) : Bool

Deprecated: use CrystalIBAN::Validator#valid? instead.

Source
validate!(iban : String) : String

Deprecated: use CrystalIBAN::Validator#validate! instead.

Source