Re #265 - extended jsonpath support (#266)

* Re #265 - Use extended JSONpath support,
Allow a JSONPath selector to not match anything (yet)
Adding test
Correctly capture invalid JSONPath query error
This commit is contained in:
dgtlmoon
2021-10-27 09:24:08 +02:00
committed by GitHub
parent c17327633f
commit a8e92e2226
3 changed files with 120 additions and 5 deletions

View File

@@ -179,7 +179,7 @@ class ValidateCSSJSONInput(object):
def __call__(self, form, field):
if 'json:' in field.data:
from jsonpath_ng.exceptions import JsonPathParserError, JsonPathLexerError
from jsonpath_ng import jsonpath, parse
from jsonpath_ng.ext import parse
input = field.data.replace('json:', '')
@@ -189,6 +189,8 @@ class ValidateCSSJSONInput(object):
message = field.gettext('\'%s\' is not a valid JSONPath expression. (%s)')
raise ValidationError(message % (input, str(e)))
# Re #265 - maybe in the future fetch the page and offer a
# warning/notice that its possible the rule doesnt yet match anything?
class quickWatchForm(Form):
# https://wtforms.readthedocs.io/en/2.3.x/fields/#module-wtforms.fields.html5