Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Make enum types pass validation #46

Open
wants to merge 1 commit into
base: next-release
Choose a base branch
from

Conversation

svenschwermer
Copy link

marshmallow 3.0.0 doesn't perform validation during dump[s]. In order to
get the equivalent behaviour as before, validate must be called. However,
this fails with "Enum name must be string" for the following MWE:

class MyEnum(Enum):
    a = 1

class MySchema(Schema):
    my_field = EnumField(MyEnum)

errors = MySchema().validate({"my_field": MyEnum.a})
assert not errors

Internally, validate calls _do_load which invokes _deserialize aon all
fields. If there is nothing to deserialize, i.e. the type is already
correct, don't do anything.

Signed-off-by: Sven Schwermer [email protected]

marshmallow 3.0.0 doesn't perform validation during dump[s]. In order to
get the equivalent behaviour as before, validate must be called. However,
this fails with "Enum name must be string" for the following MWE:

    class MyEnum(Enum):
        a = 1

    class MySchema(Schema):
        my_field = EnumField(MyEnum)

    errors = MySchema().validate({"my_field": MyEnum.a})
    assert not errors

Internally, validate calls _do_load which invokes _deserialize aon all
fields. If there is nothing to deserialize, i.e. the type is already
correct, don't do anything.

Signed-off-by: Sven Schwermer <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant