As we talked on Gitter with @codeliner , I would be interested to demonstrate the use of domain services to check, let's say, the uniqueness of an email address.
Example: Check that the user's email is not already used while registering a new user. At the moment, you can register twice with the same email address (when pressing the previous button and filling the registration form again).
Another improvement proposed by @bweston92 :
you wouldn't even do new DateTimeImmutable as it is data relied from the system so you'd have a Clock interface that would give you this information.
How
- Create a Service Interface in the Domain and its implementation in the Infrastructure.
- Pass it to the command handler so it passes it to the aggregate root's method.
- The aggregate root uses the domain service for its business rule.
As we talked on Gitter with @codeliner , I would be interested to demonstrate the use of domain services to check, let's say, the uniqueness of an email address.
Example: Check that the user's email is not already used while registering a new user. At the moment, you can register twice with the same email address (when pressing the previous button and filling the registration form again).
Another improvement proposed by @bweston92 :
How