INNER CODE UNIT · Python
as_marshmallow_field
Scille/umongo · src/umongo/abstract.py:196
def as_marshmallow_field(self): # noqa: RET503 (no explicit return)
"""Return a pure-marshmallow version of this field"""
field_kwargs = self._extract_marshmallow_field_params()
# Retrieve the marshmallow class we inherit from
for m_class in type(self).mro():
if not issubclass(m_class, BaseField) and issubclass(
m_class,
ma.fields.Field,
):
m_field = m_class(**field_kwargs, metadata=self.metadata)
# Add i18n support to the field
m_field.error_messages = I18nErrorDict(m_field.error_messages)
return m_field
# Cannot escape the loop given BaseField itself inherits marshmallow's Field
class BaseValidator(ma.validate.Validator):
"""All validators in umongo should inherit from this base validator."""