MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / validate

Method validate

mongoengine/fields.py:758–768  ·  view source on GitHub ↗

Make sure that the document instance is an instance of the EmbeddedDocument subclass provided when the document was defined.

(self, value, clean=True)

Source from the content-addressed store, hash-verified

756 return self.document_type.to_mongo(value, use_db_field, fields)
757
758 def validate(self, value, clean=True):
759 """Make sure that the document instance is an instance of the
760 EmbeddedDocument subclass provided when the document was defined.
761 """
762 # Using isinstance also works for subclasses of self.document
763 if not isinstance(value, self.document_type):
764 self.error(
765 "Invalid embedded document instance provided to an "
766 "EmbeddedDocumentField"
767 )
768 value.validate(clean=clean)
769
770 def lookup_member(self, member_name):
771 doc_and_subclasses = [self.document_type] + self.document_type.__subclasses__()

Callers

nothing calls this directly

Calls 2

errorMethod · 0.80
validateMethod · 0.45

Tested by

no test coverage detected