2

For a clean architecture where there is presentation layer (Javascript), web api layer, application/domain layer, infrastructure layer (EF Core ORM). Let's say it is an ATM system and the use case/function is Deposit. Imagine is a a web version although it doesn't make sense.

After authenticated, user enter the input data which is the deposit amount. First validation happen in presentation layer using Javascript validation library. This input type validation will match with entity validation which defined in infrastructure layer (i.e. using FluentValidation). Example it will check the data type and input length. No business rules validation happens here.

Upon pass the ui data type validation, it will issue request to web api. If the request is available and valid, it will proceed to the application/domain for business rules validation. Example, deposit amount has to be positive amount, deposit amount has to be multiple of 10.

Upon pass the application/domain for business rules validation, it will move to infrastructure layer where this will be entity validation using for example FluentValidation to ensure input data again has the valid data type and length defined in the EF Core entity model.

So basically there are 4 layers of validation? UI -> Web Api -> Application/Domain/Business -> Infrastructure (ie EF Core ORM).

Domain-Driven-Design is not needed here. So, I combine Application and Domain into same layer.

Added extra thoughts: I realize that FluentValidation has extension for Web Api which means that the flow is better imo.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.