[英]Email validation solution for front and backend
We have to do email validation and there are a large number of solution. 我们必须进行电子邮件验证,并且有大量解决方案。 The email is not the primary email we are using across site so we are not planning on sending a email and verifying the account.
该电子邮件不是我们跨站点使用的主要电子邮件,因此我们不打算发送电子邮件并验证帐户。 Hence we we are relying on regex based validation solution.
因此,我们依赖于基于正则表达式的验证解决方案。
Now doing regex based validation in server-side(java) is generally discouraged and we are advised to use existing solution like EmailValidator or existing libraries. 现在,一般不建议在服务器端(java)中进行基于正则表达式的验证,建议您使用现有的解决方案,例如EmailValidator或现有的库。 Now the problem is to achieve consistency between front end validation(which would be regex based and implemented in javascript) and backend implementation (which will be in java).
现在的问题是要实现前端验证(将基于正则表达式并在javascript中实现)和后端实现(将在java中)之间的一致性。
Is there a solution to achieve consistency between these validation on front-end and backend automatically. 是否有解决方案可以自动实现前端和后端验证之间的一致性。
I see two solutions, that might not the most optimal but that are certainly worth a try. 我看到了两个解决方案,这些解决方案可能不是最理想的,但肯定值得一试。
1) You could implement a web-service that would return the result returned by EmailValidator and then call this webservice in your javascript to do the checks. 1)您可以实现一个Web服务,该服务将返回EmailValidator返回的结果,然后在您的JavaScript中调用此Web服务进行检查。
2) Try to find the regex used by EmailValidator (assuming they use a regex), and use the same in your javascipt. 2)尝试查找EmailValidator使用的正则表达式(假设他们使用的是正则表达式),并在您的javascipt中使用相同的正则表达式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.