Types
Model alternatives with enums and validate external values before treating them as domain data.
Valid states
Why
An enum prevents combinations of optional fields that no operation can handle meaningfully.
Rules
MUST use enums for closed alternatives and Option for meaningful absence.[review]
MUST use Result for a failure with an explanation rather than overload Option.[review]
MUST keep external deserialization separate from domain validation.[review]
MUST use private fields or validated constructors when arbitrary construction would violate an invariant.[review]
MUST use generics orimpl Traitwhen static capability dispatch is sufficient.[review]
MUST justify dynamic dispatch and heap allocation rather than select them by habit.[review]
MAY use newtypes to distinguish values with the same underlying representation.[review]
[review]
The compiler checks enum and capability types. Validation tests establish invariants that types alone cannot express.
Enforcement
The compiler checks enum and capability types. Validation tests establish invariants that types alone cannot express.