在VIPER架构(Android)中,编辑文本验证发生在哪里?

huangapple go评论100阅读模式
英文:

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

问题

根据我从文章中学到的知识,我使用 VIPER 架构为我的登录界面构建了一个示例应用程序。在这个界面中,我有两个编辑框(用户名和密码)和一个按钮。当用户点击登录按钮时,我需要验证用户名和密码是否不为空,如果为空,我应该显示一个错误消息要求用户输入数据。

我的问题是,我应该把编辑框验证代码放在哪里?

在 VIPER 架构中,哪个模块负责处理这个任务?

英文:

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?

答案1

得分: 1

如https://theswiftdev.com/the-ultimate-viper-architecture-tutorial中所述,presenter区域是以非UI方式实现“业务逻辑”的地方。输入事件的验证将有两种类型:

  1. 针对“业务”/后端工程基础设施要求的有效性;
  2. 针对UI约束的有效性(例如,是否在某个范围内)。

编辑文本字段的内容几乎总是属于第一类。因此,编辑的文本字段的内容最终将传递到presenter区域,以验证密码是否符合足够安全性的最低复杂性要求。

英文:

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.

huangapple
  • 本文由 发表于 2020年9月16日 23:12:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/63923028.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定