marshmallow_union package

Module contents

class marshmallow_union.Union(fields, reverse_serialize_candidates=False, *args, **kwargs)[source]

Bases: marshmallow.fields.Field

Field that accepts any one of multiple fields.

Each argument will be tried until one succeeds.

Parameters:
  • fields (List[Field]) – The list of candidate fields to try.
  • reverse_serialize_candidates (bool) – Whether to try the candidates in reverse order when serializing.