Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best place for input validation? #96

Open
ehsankalafchi opened this issue May 31, 2020 · 4 comments
Open

Best place for input validation? #96

ehsankalafchi opened this issue May 31, 2020 · 4 comments

Comments

@ehsankalafchi
Copy link

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?

@aaghan
Copy link

aaghan commented 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
Copy link

rjmangubat23 commented 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 failure

@Zhuinden
Copy link

Zhuinden commented 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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants