Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add CedarMetadataRecord.clean #10525

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
cslzchen marked this conversation as resolved.
Show resolved Hide resolved
Loading