iban

Version, currently main branch1 version
  • main branchlatestJun 7, 2021

github.com/sikoba/IBAN.cr

No description declared in shard.yml.

2 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  iban:
    github: sikoba/IBAN.cr
    branch: main

main is a branch, not a release, so this tracks it rather than pinning a version.

Then run:

shards install

shard.yml

Crystal
>= 0.36.0
License
MIT
Authors
Dragan Postolovski, Alex Kampa
Target
  • iban from src/iban.cr

Dependencies

This version declares no dependencies.

README

IBAN.cr

Verifies the validity of IBAN International Bank Account Numbers. Verification of national check digits is not implemented.

Using this shard

Add to your shard.yml

dependencies:
  iban:
    github: sikoba/iban.cr

Then add at the beginning of your .cr

require "iban"

Check IBAN format (true/false)

Correct IBAN:

iban = "BE71 0961 2345 6769"
res = Iban.validate(iban) #=> true

Incorrect IBAN:

iban = "BE17 0961 2345 6769"
res = Iban.validate(iban) #=> false

Check IBAN format (with explicit messages)

Correct IBAN:

iban = "BE71 0961 2345 6769"
res = Iban.validate_with_feedback(iban) #=> "OK"

Incorrect IBAN:

iban = "BE17 0961 2345 6769"
res = Iban.validate_with_feedback(iban) #=> "IBAN checksum incorrect"

Format IBAN in the standard way

iban = "  Br150  0000000000  01093 2840814p2   "
res = Iban.display(iban) #=> "BR15 0000 0000 0000 1093 2840 814P 2"

Note that this function does not check if the IBAN format is correct!