[−][src]Crate iban
This crate provides an easy way to validate an IBAN (International Bank Account Number). To do
so, you can use the function parse()
. This will check the IBAN rules
as well as the BBAN structure. The provided Iban
structure provides many methods
to easy the handling of an IBAN. Many of these methods are provided via the IbanLike
trait.
When BBAN parsing fails, the error type ParseIbanError
provides useful
information about what went wrong. Additionally, the error contains BaseIban
,
which can still be used to access useful information.
Example
The following example does a full validation of the IBAN and BBAN format.
use iban::*; let account = "DE44500105175407324931".parse::<Iban>()?; assert_eq!(account.country_code(), "DE"); assert_eq!(account.check_digits(), 44); assert_eq!(account.bban(), "500105175407324931"); assert_eq!(account.electronic_str(), "DE44500105175407324931"); assert_eq!(account.to_string(), "DE44 5001 0517 5407 3249 31"); assert_eq!(account.bank_identifier(), Some("50010517")); assert_eq!(account.branch_identifier(), None);
Features
Structs
BaseIban | Represents an IBAN that passed basic checks, but not necessarily the BBAN validation. To be exact, the IBAN must be of the correct length, start with two uppercase ASCII letters, followed by two digits, followed by any number of digits and uppercase ASCII letters. Additionally its checksum should be valid. It should either contain no whitespace, or every block of four characters can be separated by a space. |
Iban | Represents an IBAN. To obtain it, make use of the |
Enums
ParseBaseIbanError | Indicates that the string does not follow the basic IBAN rules. |
ParseIbanError | An error indicating the IBAN could not be parsed. |
Traits
IbanLike | A trait that provide basic functions on an IBAN. It is implemented by both |