Skip to content

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

@lucascourot

Description

@lucascourot

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions