Search code examples
javaandroidviper-architecture

Where does Edit text validation happens in VIPER architecture ( Android )


I read couple of articles regarding VIPER. So using the knowledge i got from it, i have build an sample app using viper architecture for my login Activity. In this activity i have 2 Edittexts (username and password) and one button. Once the user click the login button i need to validate the username and password if its not null, if it is null i should show an error message asking the user to input data.

My question is, where can I put my Editext validation code?

Which VIPER module handles that job?


Solution

  • As described in https://theswiftdev.com/the-ultimate-viper-architecture-tutorial the presenter zone is where "business logic" gets implemented in a non-UI way. There would be 2 kinds of validation of input events:

    1. valid to the "business"/backend-engineering-infrastructure requirements versus
    2. valid to the constraints of the UI (e.g., within bounds of some perimeter)

    The content of an edit-textual field is almost always in category #1. Hence the content of the edited textual field would eventually make its way to the presenter zone for validation of whether, say, the password conforms to minimum complexity requirements for good-enough security.