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 ...

Get Domain Modeling Made Functional now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.