Skip to content Skip to sidebar Skip to footer

Override Field Schema Based On Data - Marshmallow

I'm just getting started with marshmallow so if there's a more elegant way to solve the issue please let me know. Fields will be varied based on the user type (student/staff) {

Solution 1:

I think what you're looking for is polymorphism.

It's not straightforward to achieve and marshmallow does not come with an easy way to do it. You can check marshmallow-oneofschema and marshmallow-polyfield. Those two third-party libraries are meant for that. They both have their pros and cons, so none of them was included in marshmallow core.

Post a Comment for "Override Field Schema Based On Data - Marshmallow"