Barf on unknown schemas (without a way to make them known, currently).

This commit is contained in:
James Muscat 2014-12-17 13:47:36 +00:00
parent 351b00aed2
commit 8badcc38e5

View File

@ -3,11 +3,19 @@ from enum import IntEnum
class Validator(object):
schemas = {}
def validate(self, json_object):
results = ValidationResults()
if "$schemaRef" not in json_object:
results.add(ValidationSeverity.FATAL, JsonValidationException("No $schemaRef found, unable to validate."))
return results
schemaRef = json_object["$schemaRef"]
if schemaRef not in self.schemas.keys():
# We don't want to go out to the Internet and retrieve unknown schemas.
results.add(ValidationSeverity.FATAL, JsonValidationException("Schema " + schemaRef + " is unknown, unable to validate."))
return results