Skip to content

Commit

Permalink
add CedarMetadataRecord.clean
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed Jan 29, 2024
1 parent a6cc44b commit 5b51c30
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 @@ -30,3 +31,10 @@ class Meta:

def __unicode__(self):
return f'(guid=[{self.guid._id}], template=[{self.template._id}])'

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 5b51c30

Please sign in to comment.