Description
Implement Iban as a ValueObject in the finance module.
Spec: IBAN with mod-97 checksum
Implementation checklist
Implementation detail
Input / Output
|
Type |
Alias |
| Input |
String |
IbanInput |
| Output |
String |
IbanOutput |
Normalization
Strip all spaces, convert to uppercase. Store internally without spaces.
Validation
- Length 15–34 characters after stripping.
- First 2 characters must be ASCII letters (country code).
- Characters 3–4 must be digits (check digits).
- All remaining characters must be alphanumeric.
- Validate using the mod-97 algorithm: move the first 4 characters to the end, replace each letter with its numeric value (
A=10, B=11, …, Z=35), interpret the result as a big integer, check that it mod 97 == 1.
Extra methods
country_code() -> &str — first 2 characters, e.g. "CZ".
check_digits() -> &str — characters 3–4, e.g. "55".
bban() -> &str — Basic Bank Account Number, characters 5 onwards.
References
Description
Implement
Ibanas aValueObjectin thefinancemodule.Spec: IBAN with mod-97 checksum
Implementation checklist
src/finance/iban.rsValueObjecttrait#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]src/finance/mod.rsandprelude# ExampleblockROADMAP.mdfrom ⬜ to ✅Implementation detail
Input / Output
StringIbanInputStringIbanOutputNormalization
Strip all spaces, convert to uppercase. Store internally without spaces.
Validation
A=10,B=11, …,Z=35), interpret the result as a big integer, check that it mod 97 == 1.Extra methods
country_code() -> &str— first 2 characters, e.g."CZ".check_digits() -> &str— characters 3–4, e.g."55".bban() -> &str— Basic Bank Account Number, characters 5 onwards.References