coding-stylebusiness-logicclean-architecture

Clean architecture - where to put input validation logic?


Perhaps in the app I have a feature allowing users to send feedback using a form with some validation logic:

Where would you put these validation logic, either in domain layer as business logic or in presentation layer as UI logic?

These logic are applied for all applications (android, iOS, web). Please note that we already had server side validation.


Solution

  • I think many developers do that in Presentation layer, specifically in ViewModel/Presenter/Controller (not in Activity/Fragment/View!). My approach is to put that logic in Domain layer. Why?