NAME
oEdtk::IBAN - validate IBAN and BIC identifiers
SYNOPSIS
use oEdtk::IBAN;
my $err = oEdtk::IBAN::iban_error($iban);
# '' when the IBAN is valid, otherwise a human readable reason
$err = oEdtk::IBAN::bic_error($bic);
DESCRIPTION
Pure-Perl validation of International Bank Account Numbers (IBAN) and Bank Identifier Codes (BIC), following the ISO-13616 and ISO-9362 structures.
Every function is called fully qualified (the module exports nothing). The *_error functions return an empty string when their argument is valid and a short English message otherwise, so a caller can decide whether to warn or reject without catching exceptions.
The fork shipped this module at version 0.8032; it was moved unmodified into the mainline at S20 of the fork-merge plan, save for a fix to iban_letter_to_number (see "BUGS").
FUNCTIONS
iban_error
my $reason = iban_error($iban);
Run every IBAN check in order and return the first failure, or ''. Checks, in order: the general shape ("is_credible_iban"), the country code ("is_valid_country"), the country-specific format ("is_valid_iban_format") and finally the checksum ("is_valid_iban_checksum"). An IBAN containing lower case letters is accepted without a checksum check, because the lower case checksum is not implemented.
bic_error
my $reason = bic_error($bic);
Return '' when the BIC has both a valid shape and a known country code, and a message otherwise.
is_valid_iban
my $ok = is_valid_iban($iban);
True when the IBAN matches its country format and its checksum is valid.
is_valid_iban_format
my $ok = is_valid_iban_format($iban);
True when the IBAN matches the length and structure registered for its country.
is_valid_iban_checksum
my $ok = is_valid_iban_checksum($iban);
True when the IBAN passes the ISO-13616 mod-97 checksum. The letters are folded to digits via "iban_letter_to_number" and the arithmetic uses bigint.
is_credible_iban
my $ok = is_credible_iban($iban);
Cheap shape check: two uppercase letters, two digits and up to thirty alphanumeric characters.
iban_country / bic_country
my $cc = iban_country($iban); # first two characters
my $cc = bic_country($bic); # characters 5 and 6
Extract the country code from an IBAN or a BIC.
is_valid_country
my $ok = is_valid_country($cc);
True when $cc is an ISO-3166 alpha-2 code, or XK (Kosovo, a widely used code that is absent from ISO-3166).
is_valid_bic
my $ok = is_valid_bic($bic);
True when the BIC has a valid shape and a known country code.
is_valid_bic_format
my $ok = is_valid_bic_format($bic);
True when the BIC follows the ISO-9362 structure: four letters (bank), two letters (country), two alphanumeric (location) and an optional three-character alphanumeric branch.
iban_letter_to_number
my $two_digits = iban_letter_to_number($char);
Convert one uppercase letter to its two-digit IBAN value (A -> 10, B -> 11, ..., Z -> 35).
is_in_list
my $ok = is_in_list($value, \@list);
Helpers: true when $value equals one element of \@list.
BUGS
The fork version of iban_letter_to_number read the global $1 instead of its argument. It worked by accident inside is_valid_iban_checksum, where $1 was set by the enclosing s///e, and returned -55 for any letter when called directly. The port reads $char; see t/int/30_iban.t.
AUTHOR
The oEdtk team.