Crate iban [] [src]

This crate provides an easy way to validate an IBAN account number. To do this, it has two functions, validate_iban which validates the IBAN format, and validate_iban_country which validates the country specific format of the account number.

Example

The following example does a complete validation of the account number:

use iban::*;

let account_number = "DE44500105175407324931";
let valid = validate_iban(account_number) &&
        validate_iban_country(account_number) == IbanCountryResult::Valid;

assert!(valid);

Enums

IbanCountryResult

The function validate_iban_country will return a variant of this enum.

Functions

validate_iban

Validate an IBAN number. The validation will detect the following mistakes:

  • The length is four or less, or longer than 34.
  • The number contains characters other than A-Z or 0-9
  • A-Z is in place of 0-9 or vice versa
  • The checksum is invalid
If none of these apply, the function will return true, otherwise it will return false. Note that this function will not check the country format. To validate the country code and the BBAN format, you should also use validate_iban_country.

validate_iban_country

Validate the BBAN part of an IBAN account number. This function will return one of three results:

Note that this check is not a substitute for validate_iban or vice versa. This function only checks the address country code and corresponding format. To verify whether the address fits the IBAN specification, you should also call validate_iban.