Skip to content

Add CardExpiryDate (finance) #30

@vhrcgcom

Description

@vhrcgcom

Description

Implement CardExpiryDate as a ValueObject in the finance module.

Spec: MM/YY; rejected if in the past at construction time

Implementation checklist

  • Create src/finance/cardexpirydate.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 — accepts "MM/YY" or "MM/YYYY" CardExpiryDateInput
Output String — normalised as "MM/YY" CardExpiryDateOutput

Normalization

Parse month and year; normalise to 2-digit year for storage and output.

Validation

  • Month must be 01–12.
  • The card must not have already expired: the expiry month/year must be >= the current month/year at construction time (a card is valid for the entire month of its expiry).

Extra methods

  • month() -> u8 — month as a number, 1–12.
  • year() -> u16 — 4-digit year, e.g. 2027.

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