Regex format validation
Opened this issue · 0 comments
adamgundry commented
When a newtype of string is declared constrained by a regex, but the regex contains a syntax error, it seems the error may not be discovered until actually trying to validate data against it, at which point error
is called. At the very least, the regex should be parsed when building the schema into the model, so the error gets reported at compile time.
Here's an example of the error:
Explict error in module Text.Regex.TDFA.String : Text.Regex.TDFA.String died: parseRegex for Text.Regex.TDFA.String failed:\\\"^+?[1-9][0-9]{1,14}$\\\" (line 1, column 3):\\nunexpected '?'\\nexpecting empty () or anchor ^ or $, an atom, \\\"|\\\" or end of input\\nCallStack (from HasCallStack):\\n error, called at ./Text/Regex/TDFA/Common.hs:29:3 in regex-tdfa-1.2.2-e01180ae0bdb6e7a9d65d42cfa90bc5379b996c695d7bb6b8f2ccddf817c15bb:Text.Regex.TDFA.Commonn