Exceptions

Exception classes for marshmallow-related errors.

exception marshmallow.exceptions.FieldInstanceResolutionError[source]

Raised when schema to instantiate is neither a Schema class nor an instance.

exception marshmallow.exceptions.MarshmallowError[source]

Base class for all marshmallow-related errors.

exception marshmallow.exceptions.RegistryError[source]

Raised when an invalid operation is performed on the serializer class registry.

exception marshmallow.exceptions.StringNotCollectionError[source]

Raised when a string is passed when a list of strings is expected.

exception marshmallow.exceptions.ValidationError(message: Union[str, typing.List, typing.Dict], field_name: str = '_schema', data: Union[typing.Mapping[str, typing.Any], typing.Iterable[typing.Mapping[str, typing.Any]], NoneType] = None, valid_data: Union[typing.List[typing.Dict[str, typing.Any]], typing.Dict[str, typing.Any], NoneType] = None, **kwargs)[source]

Raised when validation fails on a field or schema.

Validators and custom fields should raise this exception.

Parameters:
  • message – An error message, list of error messages, or dict of error messages. If a dict, the keys are subitems and the values are error messages.
  • field_name – Field name to store the error on. If None, the error is stored as schema-level error.
  • data – Raw input data.
  • valid_data – Valid (de)serialized data.