Make sure that the document instance is an instance of the EmbeddedDocument subclass provided when the document was defined.
(self, value, clean=True)
| 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__() |