Dev.to
6/16/2026

The third enum variant that stopped my tax calculator from lying
Short summary
Building a US tax calculator with incomplete state tax data, the author discovered a critical pattern: represent unverified states as a first-class enum variant (pending) rather than treating them as verified, preventing quiet bugs where numbers masquerade as facts. This forces type systems to distinguish zero from unknown from verified. Apply the same principle to any system with incomplete data—model absence explicitly in types rather than collapsing it into null or placeholders.
- •Use a third enum variant to explicitly represent unverified/pending data states
- •Type systems should prevent collapsing 'no value', 'unknown value', and 'verified value' into the same representation
- •Pattern generalizes beyond tax code to any domain with incomplete data
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



