Parse, don't validate
Make invalid states unrepresentable in your type system rather than checking validity at runtime.
https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/
Make invalid states unrepresentable in your type system rather than checking validity at runtime.
https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/