I’ve designed a domain model following DDD methodology. I would like to add validation.
Do you think adding validation at the domain model level is a good idea? If no, where should I validate my domain objects?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If the validation rules form part of the business domain, they belong in the model.
An aggregate root is responsible of maintaining the invariants encompassed by it, so validating them falls under its responsibility.
If you find that the validation rules are very complex, you can create a validation service that will be used by the aggregate root for this function.