-
-
-def _get_validator(schema_path):
- """Contruct validator with format checking enabled.
-
- Load json schema from disk.
- Perform validation against meta-schema before returning.
-
- :param schema_path: Local filesystem path to .json file storing the schema.
- :type schema_path: str
- :returns: Instantiated validator class instance.
- :rtype: jsonschema.validators.Validator
- :raises RuntimeError: If the schema is not valid according its meta-schema.
- """
- with open(schema_path, u"rt", encoding="utf-8") as file_in:
- schema = json.load(file_in)
- validator_class = jsonschema.validators.validator_for(schema)
- validator_class.check_schema(schema)
- fmt_checker = jsonschema.FormatChecker()
- validator = validator_class(schema, format_checker=fmt_checker)
- return validator