简体   繁体   English

如何根据逻辑动态生成前端验证

[英]How to dynamically generate Validations for the Front end depending upon the Logic

Consider the page below. 考虑下面的页面。 As in the image I have attached. 就像我所附的图片一样。 在此处输入图片说明

Now my problem is that I have multiple clients accessing the same page as given below. 现在,我的问题是我有多个客户端访问同一页面,如下所示。 Now consider that each client has their own requirement such as:- 现在考虑每个客户都有自己的要求,例如:

  1. Name is mandatory for some clients not for others. 名称对于某些客户是必需的,对于其他客户则不是。
  2. Age is mandatory for some clients but not for others along with some specific validations like age<20 or age>30 etc. 对于某些客户,年龄是必填项,但对于某些客户则不是强制性的,并带有一些特定的验证,例如年龄<20或年龄> 30等。
  3. Search is also optional depending upon the clients. 搜索也是可选的,具体取决于客户端。

Now I am searching for any such tools or technologies or methods that could help me to sort out the issue of dynamically validating the fields as well as hiding and showing the fields depending upon my clients. 现在,我正在寻找可以帮助我解决动态验证字段以及根据客户隐藏和显示字段的问题的任何此类工具或技术或方法。 Please let me know any tools or technologies that can help in order to solve the above problem. 请让我知道可以解决上述问题的任何工具或技术。 I also heard about rule engine and templating .... Is it possible to work together with it to achieve the same. 我还听说过规则引擎和模板....是否可以与之一起实现相同的目的。 Please suggest. 请提出建议。

I have no idea why hibernate-validator would not work here. 我不知道为什么休眠验证器在这里不起作用。 You implement the validation as you want, by implementing an interface and creating your own validation annotations if needed. 您可以通过实现接口并根据需要创建自己的验证批注来实现所需的验证。 This is a server-side validation btw. 这是服务器端验证。

Showing or not some content in case of JSP is done with conditional : 在有条件的情况下,显示或不显示某些JSP内容:

c:when/c:choose 

for example, assuming it's JSP you are using. 例如,假设您使用的是JSP。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM