In this post I will be referring back to simplified versions of my regex's (regular expressions) from my previous post on form validation. That re...
For further actions, you may consider blocking this person and/or reporting abuse
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
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
"you cannot assign a regex defined as a literal to a variable"
I'm not sure if I got this right and could probably a stupid question. But by saying you cannot assign, do you mean that the following is invalid or frowned upon?
Hmm I could be wrong I was trying something like this but it was barfing on the \d I think, as soon as I used new RegExp and escaped the \d with a slash it worked.