Skip to content

Best place for input validation? #96

Open
@ehsankalafchi

Description

@ehsankalafchi

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?

Activity

aaghan

aaghan commented on Jun 9, 2020

@aaghan

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

rjmangubat23 commented on Aug 4, 2020

@rjmangubat23

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

Zhuinden commented on Aug 4, 2020

@Zhuinden

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

AbhishekCharde commented on Sep 24, 2020

@AbhishekCharde

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Best place for input validation? · Issue #96 · android10/Android-CleanArchitecture-Kotlin