I read that in general the domain model should be as pure as possible and not have to depend on things in the application and infrastructure level.I have 2 examples:1. I have a user entity which is an aggregate root. The entity contains an email address value object. There is an invariant that each user's email address must be unique. How do I enforce this invariant when a user is created or changes his email address? Should the validation be in user.UpdateEmailAddress() and the constructor (new User(EmailAddress email))? Wouldn't this require the User entity to have a reference to the UserRepository which has the userRepository.FindUserByEmail() method?
--
You received this message because you are subscribed to the Google Groups "DDD/CQRS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dddcqrs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
There is an invariant that each user's email address must be unique. How do I enforce this invariant when a user is created or changes his email address?
Before storing the token to my database, I need to verify that the token is valid by using the REST api of my payment gateway. Since this means something in my domain model needs to touch the infrastructure, it seems like a big no-no. How should this be modelled?
Hi Jack,