I was wondering whether there is a way in marshmallow to have a field to be required depending on another value.
Eg:
{ 'name':'Tom' }
{ 'name':'Arthur', 'job':'teacher' }
I'd like to know if there is a way to make the field job required if isWorking=True (isWorking is not a field in the schema)
You may use a schema validator with marshmallow.decorators.validates_schema.
If you set
pass_original=True, you'll get input data in which you'll findisWorking. Then you can raise aValidationErrorifjobis missing.