You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I guess no validation logic is provided in this sample. Where is the best place to write validation logic in clean architecture? in Views, ViewModels, Use Cases, Models or Data Entities? Or maybe each layer must have its own validators?
In my case, I usually just handle validation logic in the repo and if validation fails I call a Left(Failure) and then in the view(fragment) I handle the failure
Depend on requirement. We can set validation on View, ViewModel or Model part also.
As per my suggestion its better to set validation on View part so it will show validation on runtime.
Activity
aaghan commentedon Jun 9, 2020
it depends what and where you want to validate,
if you want to validate on the views itself
or if you want to validate before api call
rjmangubat23 commentedon Aug 4, 2020
In my case, I usually just handle validation logic in the repo and if validation fails I call a
Left(Failure)
and then in the view(fragment) I handle the failureZhuinden commentedon Aug 4, 2020
I believe it should be a result type of a sealed class of a "Result class per UseCase" approach.
But input validation should occur in ViewModel.
AbhishekCharde commentedon Sep 24, 2020
Depend on requirement. We can set validation on View, ViewModel or Model part also.
As per my suggestion its better to set validation on View part so it will show validation on runtime.