Description
Implement CardExpiryDate as a ValueObject in the finance module.
Spec: MM/YY; rejected if in the past at construction time
Implementation checklist
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
Description
Implement
CardExpiryDateas aValueObjectin thefinancemodule.Spec: MM/YY; rejected if in the past at construction time
Implementation checklist
src/finance/cardexpirydate.rsValueObjecttrait#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]src/finance/mod.rsandprelude# ExampleblockROADMAP.mdfrom ⬜ to ✅Implementation detail
Input / Output
String— accepts"MM/YY"or"MM/YYYY"CardExpiryDateInputString— normalised as"MM/YY"CardExpiryDateOutputNormalization
Parse month and year; normalise to 2-digit year for storage and output.
Validation
Extra methods
month() -> u8— month as a number, 1–12.year() -> u16— 4-digit year, e.g.2027.References