INNER CODE UNIT · Python

_validate_missing

Scille/umongo · src/umongo/abstract.py:155

    def _validate_missing(self, value):
        # Overwrite marshmallow.Field._validate_missing given it also checks
        # for missing required fields (this is done at commit time in umongo
        # using `DataProxy.required_validate`).
        if value is None and getattr(self, "allow_none", False) is False:
            self.fail("null")

    def serialize_to_mongo(self, obj):
        if obj is None and getattr(self, "allow_none", False) is True:
            return None
        if obj is ma.missing:
            return ma.missing
        return self._serialize_to_mongo(obj)

    def deserialize_from_mongo(self, value):
        if value is None and getattr(self, "allow_none", False) is True:
            return None
        return self._deserialize_from_mongo(value)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…