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

Implementing the Validation Step

We can now start implementing the validation step. The validation step will take the unvalidated order, with all its primitive fields, and transform it into a proper, fully validated domain object.

We modeled the function types for this step like this:

 type​ CheckAddressExists =
  UnvalidatedAddress -> AsyncResult<CheckedAddress,AddressValidationError>
 
 type​ ValidateOrder =
  CheckProductCodeExists ​// dependency
  -> CheckAddressExists ​// AsyncResult dependency
  -> UnvalidatedOrder ​// input
  -> AsyncResult<ValidatedOrder,ValidationError ​list​> ​// output

As we said, we’re going to eliminate the effects for this chapter, so we can remove the AsyncResult parts, leaving us with this:

 type​ CheckAddressExists ...

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