diff --git a/osf/models/cedar_metadata.py b/osf/models/cedar_metadata.py index 1f7a19cbf8f..73d004c947c 100644 --- a/osf/models/cedar_metadata.py +++ b/osf/models/cedar_metadata.py @@ -1,6 +1,7 @@ from django.db import models from osf.models.base import BaseModel, ObjectIDMixin +from osf.models.validators import JsonschemaValidator from osf.utils.datetime_aware_jsonfield import DateTimeAwareJSONField @@ -43,3 +44,10 @@ def get_template_name(self): def save(self, *args, **kwargs): self.guid.referent.update_search() return super().save(*args, **kwargs) + + def clean(self): + super().clean() + _cedar_template_jsonschema = self.template.template + _cedar_record_json = self.metadata + # raises django.core.exceptions.ValidationError when invalid + JsonschemaValidator(_cedar_template_jsonschema)(_cedar_record_json)