re: Regex Bootcamp (or Nobody Seems to be Using HTML5 Validation) VIEW POST

FULL DISCUSSION
 

Regexes are easy and useful in the backend, but I feel like they are extremely user-unfriendly.
How do I explain the "requested format" to the end user?
That's why I feel like something like a declaratively composed validator is more useful, since it can say which attribute of the string is wrong.

 

You realize regex's ARE declarative? "Common declarative languages include those of database query languages (e.g., SQL, XQuery), regular expressions": en.wikipedia.org/wiki/Declarative_...

 

Sure, and you could even reverse-engineer some messages, but you'd get something like

Phone must begin with "00" or "+" or nothing, followed by "1" or "7" or "20" or "27" or "3...

Whereas with a proper syntax description you could automatically insert a "+", delete a leading "00", and if the following two digits aren't a real country code have an informative error like

Please include the country code in the phone number

code of conduct - report abuse