mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-20 06:52:15 +00:00
Make validation error more verbose
This commit is contained in:
@@ -81,13 +81,13 @@ class Form(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
schemaValue = json.loads(self.schema.schema)
|
schemaValue = json.loads(self.schema.schema)
|
||||||
jsonschema.validate(jsonData,schemaValue) #This will raise ValidationError if data doesn't match schema
|
jsonschema.validate(jsonData,schemaValue) #This will raise jsonschema.ValidationError if data doesn't match schema
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
pass #halfway through creation this can cause issues
|
pass #halfway through creation this can cause issues
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise ValidationError('Invalid JSON in schema, cannot validate')
|
raise ValidationError('Invalid JSON in schema, cannot validate')
|
||||||
except jsonschema.ValidationError: #raise a django exception
|
except jsonschema.ValidationError as e: #raise a django exception
|
||||||
raise ValidationError('Data is not valid, cannot save')
|
raise ValidationError('Data is not valid, cannot save: '+e.message)
|
||||||
|
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
|
|||||||
Reference in New Issue
Block a user