Domain Validation in a CQRS architecture

前端 未结 11 1497
南旧
南旧 2020-12-12 11:25

Danger ... Danger Dr. Smith... Philosophical post ahead

The purpose of this post is to determine if placing the validation logic outside of my domain entiti

11条回答
  •  囚心锁ツ
    2020-12-12 11:37

    You can use a message based solution with Domain Events as explained here.

    Exceptions are not the right method for all validation errors, is not said that a not valid entity is an exceptional case.

    If the validation is not trivial, the logic to validate the aggregate can be executed directly on the server and while you are trying to set new input you can raise a Domain Event to tell to the user (or the application that is using your domain) why the input is not correct.

提交回复
热议问题