Should I abstract the validation framework from Domain layer?

后端 未结 3 1967
猫巷女王i
猫巷女王i 2020-11-27 03:59

I am using FluentValidation to validate my service operations. My code looks like:

using FluentValidation;

IUserService
{
    void Add(User user);
}

UserSe         


        
3条回答
  •  时光取名叫无心
    2020-11-27 04:16

    Answer on your question depends what kind of validation you want put into validator class. Validation can be part of domain model and in your case you've implemented it with FluentValidation and I not see any problems with that. The key thing of domain model - you can use your domain model everywhere, for example if your project contains web part, api, integration with other subsystems. Each module reference to your domain model and works same for all.

提交回复
热议问题