Skip to content

Add Iban (finance) #23

@vhrcgcom

Description

@vhrcgcom

Description

Implement Iban as a ValueObject in the finance module.

Spec: IBAN with mod-97 checksum

Implementation checklist

  • Create src/finance/iban.rs
  • Implement ValueObject trait
  • Add #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
  • Export from src/finance/mod.rs and prelude
  • Unit tests: valid input · empty input · invalid format · normalisation
  • Doc comment with # Example block
  • Update status in ROADMAP.md from ⬜ to ✅

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvement

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions