Hi,
I have some validation rules that place a restriction on word counts. This can be achieved with a regular expression - one that matches words and does so up to a maximum count. For example, this regex "^(?:\\b\\w+\\b[\\s\\r\\n]*){1,50}$" matches up to 50 words (but needs some fine tuning, it does not allow much punctuation).
The trouble with the regex approach, is that UI code has no way of understanding what the intention of the regex is, so it is hard to generate a good error message for this. Ideally the error message would say "must enter 50 words or less".
Word count might be a tricky thing to standardize, what punctuation is allowed and what about different languages, and so on.
Would it make sense for json-schema to have a word count validation keyword?
Would it make sense for json-schema to explicitly define a user extensible mechanism for adding new validations that are not part of its base specification? This would mean for example, that if I add my own "word-count" validation keyword, I could reasonably expect tools built around json-schema to not fail when encountering a non-standard keyword, and to provide extension points to invoke a call-back in my code in order to apply the validation check for my definition of word-count.
Rupert
p.s. As a workaround we are hard-coding some of our error messages in the UI. For the word-count case, we just hard code an error message giving the correct validation for that field, for example "Must be 50 words or less and a maximum of 1000 characters".