Function iban::validate_iban [] [src]

pub fn validate_iban(address: &str) -> bool

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.

Examples

use iban::validate_iban;

// A valid address
assert_eq!(validate_iban("DE44500105175407324931"), true);

// An invalid address
assert_eq!(validate_iban("DE4450010234607324931"), false);