O'Reilly logo

Domain Modeling Made Functional by Scott Wlaschin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Capturing Business Rules in the Type System

Let’s look at another modeling challenge: can we document business rules using just the type system? That is, we’d like to use the F# type system to represent what is valid or invalid so that the compiler can check it for us, instead of relying on runtime checks or code comments to ensure the rules are maintained.

Here’s a real-world example. Suppose our company, Widgets Inc, stores email addresses for its customers. But let’s also suppose not all email addresses should be treated the same way. Some email addresses have been verified—that is, the customer got a verification email and clicked on the verification link—while other email addresses aren’t verified and we can’t be sure they’re valid. Furthermore, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required