DevPath

Model money with a validated dataclass

Foundation · fluency · 20 min · runtime python

Brief

Define a frozen dataclass Money(amount_cents: int, currency: str) that rejects negative amounts and currency codes that are not three uppercase letters. Include type hints.

3 progressive hints are available in the editor.

Public checks

  • accepts valid money — expected: constructs
  • rejects negative — expected: raises ValueError