Skip to content

Commit

Permalink
add CedarMetadataRecord.clean
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed Feb 1, 2024
1 parent 23f3171 commit bdb8ad8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions osf/models/cedar_metadata.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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)

0 comments on commit bdb8ad8

Please sign in to comment.