Add a new feature to the hall of fame to demonstrate how to check uniqueness #92

lucascourot opened this Issue Oct 21, 2016 · 0 comments


None yet
2 participants

lucascourot commented Oct 21, 2016

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.


  • 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment