针对传统数据验证方案在验证场所的单一性或验证场所分工不明确而导致的用户体验差、系统效率低,以及验证代码与系统其它模块耦合度较大的问题,提出了一种以验证复杂度为依据来进行验证场所在数据验证方面的明确分工策略。设计了一个在客户端采用事件监听减少客户端UI和验证代码的耦合度,在服务器端运用Aop和Valang分离数据验证模块和业务逻辑模块的方案。该方案能以少代码、低耦合的方式实现数据验证功能,并在实际项目中有较好的实用性。
Traditional data verification plan have the problem of user experience deficiency, system efficiency and high coupling degree of validation code with other system module, brought by simplicity and work division indeterminacy. This paper poses a definite division strategy based on complexity verification to validate places, designing a plan using event listener on the client side to reduce coupling degree of UI and verification code and utilizing Aop and Valang to separate data verification and business logic module on the server. This plan is very practical in projects as it can realize data verification function with short code and low coupling.