从正则表达式正确UI验证错误 - From regular expression to a correct UI validation error

- 此内容更新于:2015-12-20
主题:

我们使用一个服务,发送预订所需字段的列表(..)的东西。输出:Field_1验证:[\s/0-9A-Z]{1105}Field_2等。在UI上我们想将其映射到英语文本(或其他语言,但现在我们假设英语)。UI验证错误将是:“请输入一个有效的格式:字母字符和/或空间”从1到105的想法将是任何正则表达式转化为文本。我想知道,如果这已经解决了吗?

原文:

We use a service that sends a list of fields required for a booking (of something..). The output looks like :

  1. Field_1 Validation: [-\s/0-9A-Z]{1,105}
  2. Field_2 etc..

On the UI we would like to map it to English text (or other languages, but let's assume English now). The UI validation error would be:

"Please enter a valid format : Alphabetical characters and/or space from 1 to 105"

The idea would be to translate any regex into text..

I wanted to know, if this has already been tackled before?

网友:你可以将人类可读的错误消息添加到你的列表:Field_1验证(正则表达式)的信息:“……”。但恕我直言,这当然是不太有用的。更有助于告诉人们他们失踪,如。“必须至少有一个数字”,因此,你需要有多个检查,对于每一次这样的错误条件。

(原文:You could just add the human readable error message to your list: Field_1 Validation[regex] Message: "...". But IMHO that is not too helpful. It would be more helpful to tell people what they're missing, e.g., "must have at least one digit", and for that you need to have multiple checks, one for each such error condition.)

网友:你用的什么语言?“语言”并不是一个非常有用的标记。stackoverflow.com/questions/17296563/?

(原文:What language are you using? "Language" isn't a very helpful tag. stackoverflow.com/questions/17296563/…)

网友:我不介意语言,但更多的可能是如何处理无论在语言..我把语言标签..谢谢你的答案!顺便说一下!

(原文:I don't mind which language, but more how it could be handled regardless on the language.. I removed the language tag.. Thank you for your answers ! by the way !)