我是科索沃统计局的新鲜事,我很抱着在书写方面(主要)对商业规则的验证感。 我知道,应当根据有效日期(要求外地、缩短时间、有效电子邮件等)和在业务规则/业务领域进行相关的验证。 实际上,也应适用同一客户方验证规则,以控制该领域,因为我们不相信用户。
因此,我们有有效的指挥(ToCustomer先生),指挥员被援引。 这里是我的验证方法。
- Create instances of two command validators in the command handler.
- First one validates the command data same as client side validation (required field, valid email, etc.)
- Second validator validates the data based on logic within the second validator. Something like "is this customer active", or what ever. I know the changing email doesn t fit here but it is not important. Important thing is there is a business validation here.
- We look at the ValidationResult returned by the Validator.Validate(ICommand cmd) and we find out there are errors
- We will not get a customer from repository to call on the UpdateEmail method on the AR. So what do we do at this point?
Do I throw and exception in the command handler and add these errors there? Do I send the command to error queue or somewhere else? Do I respond with something like Bus.Reply and return error code? If so, what do I do with the error messages? How do I communicate these errors to the user? I know I can email them later but in a web scenario I can send a request id in the command (or use the message id), and poll for response with the request id and display the error messages to user.
赞赏你的指导。
增 编