Re:Semantic Validation in Rust
by maxdeviant on Thursday September 05, 2019 @02:35PM
(#20889533)
The problem I have with this style of validation is that it doesn't "make illegal states unrepresentable". If the validation is not run then it is still possible for instances of `ContactData` that violate the business rules to enter the system.
In this case, all of the above rules can be encoded into the type system itself. Here's how I would approach this particular problem:
This approach, when applied alongside Rust's modules and visibility modifiers, would make it impossible for any of these types to be in an invalid state.
[ Parent
| on HN ]
There are no comments on this comment yet.