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, List, Dict], field_name: str = '_schema', data: Optional[Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]] = None, valid_data: Optional[Union[List[Dict[str, Any]], Dict[str, Any]]] = 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.