pub fn validate_iban(s: &str) -> Result<(), ValidationError>Expand description
Validate an ISO 13616 IBAN (International Bank Account Number) via the mod-97 check. Strips spaces (the typical printed “GB82 WEST 1234 5698 7654 32” shape) before validating.
Format requirements:
- 2-letter ISO country code (uppercase).
- 2-digit check digits.
- 1–30 additional ASCII alphanumeric chars.
- Total length 5–34.
Algorithm:
- Move the first 4 chars to the end.
- Replace each letter with two digits: A=10, B=11, …, Z=35.
- Treat the result as a single integer; mod 97 must equal 1.
This catches typos before hitting the bank-rails verification API. Does NOT verify the account exists / has funds — only the payment provider can do that.
§Errors
ValidationError { code: "invalid_iban", ... }.