Closed simkimsia closed 2 years ago
You probably want a OneOf validator: https://marshmallow.readthedocs.io/en/stable/marshmallow.validate.html#marshmallow.validate.OneOf
e.g.
import marshmallow as ma
class FooSchema(ma.Schema):
bar = ma.fields.String(validate=ma.validate.OneOf(["fizz", "buzz"]))
print(FooSchema().load({"bar": "fizz"}))
print(FooSchema().load({"bar": "uhoh"}))
I think this is a pretty straightforward "yes, marshmallow supports that" case, so I'm going to close it. 🙂
So I want the currency to only allow values of
['USD', 'GBP', 'EUR']
and disallow everything else.How do I do that?