marshmallow
marshmallow copied to clipboard
Emit warning when user passes string instead of list to OneOf
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.