Map commands to value objects in CQRS

by Mohsen   Last Updated July 21, 2018 14:05 PM

On one hand, the invariants should be protected (To make invalid states impossible early and preferably at compile time rather than run time), and on the other hand, passing domain knowledge out of the domain is wrong.

On one hand, the value objects protect our domain invariants at first place, on the other hand using them as commands or as it's properties equals passing domain knowledge around.

The only solution for both protecting the invariants, and avoiding the domain knowledge from leaking the domain boundary (encapsulating the domain model), seems to wrap the aggregates in a command-to-value-object-mapper.

I'm using CQRS along with ES.

Is it ok to have a wrapper as a command-to-value-object-mapper around my aggregate roots? Is there any other solution?

Related Questions

CQRS and DDD terminology

Updated August 27, 2018 23:05 PM

get aggregate id based on its data in it

Updated October 02, 2018 10:05 AM

How to create new aggregate root in CQRS?

Updated February 21, 2017 13:05 PM