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