Closed ferrius closed 5 years ago
By doing this your aggregates will grow a lot. And your aggregate will need to deal with logic than can be encapsulated in a better way. It will also simplify your tests suite and allow you to reuse and also cast this object in another places.
Here for example: https://github.com/jorge07/symfony-4-es-cqrs-boilerplate/blob/master/src/Domain/User/Specification/UniqueEmailSpecificationInterface.php#L15
It will ensure you receive a valid email and not just an string. By doing this you guarantee consistency and symplify test suite.
I understand, thank you
You're very welcome
IMHO value objects should carry more complex business logic than validation rules. Wrapping every scalar value in own class complicates simple things. The best way i think to use private setters with assertions inside.