def validate_social(self, value): schema = from_json('social-schema.json') try: jsonschema.validate(value, schema) except jsonschema.ValidationError as e: raise InvalidModelValueError(e) return value
def validate_social(self, value): schema = from_json('social-schema.json') try: jsonschema.validate(value, schema) except jsonschema.ValidationError as e: raise InvalidModelValueError(e) return value
def validate_metadata(self, value): schema = from_json(self.instance.serializer.osf_schema) try: jsonschema.validate(value, schema) except jsonschema.ValidationError as e: if e.relative_schema_path[0] == 'additionalProperties': error_message = e.message else: error_message = 'Your response of {} for the field {} was invalid.'.format( e.instance, e.absolute_path[0], ) raise InvalidModelValueError(detail=error_message, meta={'metadata_schema': schema}) return value
def validate_metadata(self, value): schema = from_json(self.instance.serializer.osf_schema) try: jsonschema.validate(value, schema) except jsonschema.ValidationError as e: if e.relative_schema_path[0] == 'additionalProperties': error_message = e.message else: error_message = 'Your response of {} for the field {} was invalid.'.format( e.instance, e.absolute_path[0], ) raise InvalidModelValueError(detail=error_message, meta={'metadata_schema': schema}) return value
def validate_metadata(self, proposed_metadata): return jsonschema.validate(proposed_metadata, from_json(self.serializer.osf_schema))