Expand description
A short example illustrating a simple library usage
extern crate iban_validation_rs;
use iban_validation_rs::{validate_iban_str, Iban};
// This function attempts to create an IBAN from the input string and prints the IBAN, bank ID, and branch ID if successful — or an error message if the creation fails.
fn print_iban_or_error(s: &str){
match Iban::new(s) {
Ok(iban) => {
println!("IBAN: {}", iban.get_iban());
match iban.iban_bank_id {
Some(bank_id) => println!("Bank ID: {}", bank_id),
None => println!("Bank ID: Not available"),
}
match iban.iban_branch_id {
Some(branch_id) => println!("Branch ID: {}", branch_id),
None => println!("Branch ID: Not available"),
}
}
Err(e) => println!("Failed to create IBAN due to {:?} for input: {:?}", e, s),
}
}
fn main() {
println!("okay? {:?}", validate_iban_str("DE44500105175407324931"));
print_iban_or_error("DE44500105175407324931");
print_iban_or_error("FR1234");
}
Structs§
- Iban
- Indicate how a valid Iban is stored. A owned String for the iban, so that if the String we tested is out of scope we have our own copy. TODO is it an issue? If valid for the country the slice of the Iban representing the bank_id bank identifier. If valid for the country the slice of the Iban representing the branch_id Branch identifier.
- Iban
Fields - indicate which information is expected from the Iban Registry and in the record.
Enums§
- Validation
Error - indicate what types of error the iban validation can detect
Functions§
- get_
source_ file - Indicates which file was used a source
- get_
version - Indicates the version used. to be used in other modules like the c wrapper where this infomration is not available.
- validate_
iban_ get_ numeric - Validate than an Iban is valid according to the registry information Give the results by numerical values (0,0 when the optional part is missing). This is meant to be used in c wrapper when copying value is expensive.
- validate_
iban_ str - Validate than an Iban is valid according to the registry information return true when Iban is fine, otherwise returns Error.
- validate_
iban_ with_ data - Validate than an Iban is valid according to the registry information return true when Iban is fine, together with information about the fields (so that it does not need to be looked up again later)