Enhance error messages of "pattern constraint" errors
Currently regex are used to match values against a pattern, but error messages quality is poor.
When pattern constraint is not used abusively (i.e. when it would have been OK to use a number), it's be possible to use a PEG grammar parser library or a parser library to produce better error messages.
Technical steps
-
create a custom check (named like
PegCheck
) taking a grammar and a column name (or many) - for each field using a pattern constraint:
- don't use the pattern constraint in the schema, just use
"type": "string"
- explain in the field description the form of expected value
- use examples (even if not yet supported, cf https://github.com/frictionlessdata/specs/issues/384)
- configure the custom check for this field
- don't use the pattern constraint in the schema, just use
-
define grammars outside, in
.peg
files, and reference them by path (?)
Resources
Parsers:
PEG grammars parsers:
- https://github.com/erikrose/parsimonious
- https://github.com/igordejanovic/Arpeggio
- article: https://tomassetti.me/parsing-in-python/
Other approaches: