filter Python unicode string prefix from jsonschema validation errors.

see: https://github.com/ansible/ansible-tower/issues/6417
This commit is contained in:
Ryan Petrello
2017-07-31 15:20:22 -04:00
parent 9c29b0a92f
commit 63273d8ffd

View File

@@ -385,6 +385,9 @@ class JSONSchemaField(JSONBField):
self.schema(model_instance),
format_checker=self.format_checker
).iter_errors(value):
# strip Python unicode markers from jsonschema validation errors
error.message = re.sub(r'\bu(\'|")', r'\1', error.message)
if error.validator == 'pattern' and 'error' in error.schema:
error.message = error.schema['error'] % error.instance
errors.append(error)