marshmallow icon indicating copy to clipboard operation
marshmallow copied to clipboard

Emit warning when user passes string instead of list to OneOf

Open lafrech opened this issue 1 year ago • 2 comments

I just got caught.

I wrote

    validate=validate.OneOf("one", "two")

instead of

    validate=validate.OneOf(["one", "two"])

"one" would pass because "one" in "one" is True.

It might save users trouble if we emitted a warning when a string is passed instead of a non-string iterable.

In practice, it only affects lists made of two elements (or one but users would use Equal), so no big deal.

lafrech avatar Nov 25 '22 08:11 lafrech