i18n验证 [英] i18n Validations

查看:87
本文介绍了i18n验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

思考全球化,就地行动

这就是他们告诉你的,但是在我作为开发人员的整个过程中,我总是见过像Google,Microsoft,Oracle这样的大公司,并且以本地化的方式进行验证:他们知道我来自哪个国家/地区,因此他们会尝试使用适用于我所在国家/地区的正确验证方法来验证我的电话号码,邮政编码和其他详细信息(例如银行帐号).昨天我注册了Google Checkout,他们甚至向我展示了我所在国家的一些邮政编码格式示例!

That's what they tell you, however during all my time as I developer I've always seen big companies like Google, Microsoft, Oracle and so do validations in a localized manner: they know which country I'm from so they will try to validate my phone number, postal code and other details such as bank account numbers with the proper validation methods for my country. Yesterday I signed up for Google checkout and they even showed me some examples of postal code formats in my country!

所以我的问题是,他们如何做到这一点?我知道他们有成千上万的员工,但是我很难相信他们都必须重新发明油井.美国有无数的验证方法,但世界其他地区呢?我还没有看到一个开源的像样的库(除了非常不完整和过时的库之外) PEAR尝试)对国家/地区的各种常见方面进行验证,例如:

So my question is, how do they do this? I know that they have thousands of employees but I find it hard to believe that they all had to reinvent the well. There are countless validations methods for the US but what about the rest of the world? I've not yet seen a single open source decent library (apart from a very incomplete and outdated PEAR attempt) to perform validations on various common aspects of countries such as:

  • 市民ID
  • 税号
  • SSN(社会保险号)
  • BBAN(基本银行帐号)
  • 传真,电话和手机号码
  • 邮政编码/邮政编码
  • 车牌
  • 钞票序列号
  • 依此类推...
  • Civil ID
  • Tax ID
  • SSN (Social Security Number)
  • BBAN (Basic Bank Account Number)
  • Fax, Phone and Mobile Numbers
  • Postal / Zip Codes
  • License Plates
  • Banknote Serial Numbers
  • and so on...

是否有我不知道的隐藏资源?

Is there any well hidden resource that I'm unaware of?

推荐答案

简单验证和完全验证之间存在巨大差异.通常不可能在所有区域设置完全标准化的验证,这是两个示例:

There's a huge difference between simple and full validation. It is often impossible to standardize validation fully across locales, here are a couple of examples:

  • CivilID/SSN等数字可以允许/禁止替代值(特定于系统),外来值,历史值等.针对同一领域,我们在其中一个应用程序中有2种不同的验证系统,具体取决于上下文,其他IT系统可能还有其他验证系统.

  • CivilID/SSN etc. numbers can allow/disallow substitute values (system specific), foreign values, historic values etc. We have 2 different validation systems in one of our applications for the same field, depending on context, and other IT systems may have other validation systems.

邮政编码验证可能需要访问有效值列表,这是您需要预订的内容.在许多国家/地区,这种订阅不是自动进行的,并且由于版权规则的原因,重新分发并不容易.

ZIP code validation may require access to a list of valid values, which is something you need to subscribe to. In many countries, this subscription is not automated, and because of copyright rules, it is not trivial to redistribute.

电话号码也有类似的问题.你们允许贵重的号码,手机号码吗?您如何检测到它们?

Phone numbers have a similar problem. Do you allow expensive numbers, mobile phone numbers? How do you detect them?

您可能会争辩说,在大多数情况下都可以进行简单的验证-但对于简单的验证,通常更容易使用模式匹配并让每个市场的本地部门定义有效模式.

You may argue that a simple validation is possible in most cases - but for simple validation, it is often easier to use pattern matching and to let the local department in each market define the valid patterns.

软件服务合同也存在问题.如果您购买软件并希望使用5年,那么如果有什么变化,可以更改验证规则至关重要.在我的国家/地区,我经历了电话号码系统的4项更改,这些更改影响了简单的验证,例如数字位数"和第一位数可以是什么".

There is also a problem with the software service contract. If you buy software and want to use it for 5 years, then it is vital that you can change the validation rules, if something changes. I have experienced 4 changes of the phone number system in my country that affected simple validation like "number of digits" and "what can the first digit be".

因此,最好的解决方案是拥有一个特定于区域设置模式的集中式数据库,并允许管理员修改验证模式.

Therefore, the best solution is to have a centralized database of locale-specific patterns, and to allow the administrators to modify the validation patterns.

这篇关于i18n验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆