-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
I have a custom schema that looks like the following.
class NewOrderSchema(Schema):
customer_id = CustomerEntity()
order_items = ForEach(OrderItemSchema(), if_missing=NoDefault, not_empty=True)
payment_method_id = Int(min=0, if_empty=0)
status_id = Int(min=0, if_empty=0)
notes = String(if_empty='')
return_url = String(if_empty='/')
The problematic line is this one:
order_items = ForEach(OrderItemSchema(), if_missing=NoDefault, not_empty=True)
The intent I'm trying to express in the schema is that I should NOT receive an empty list of nested OrderItemSchemas.
I find that in order for this to work, I must specify the if_missing=NoDefault keyword argument in addition to not_empty=True. It took me a long time to figure this out, since I assumed that passing not_empty=True to ForEach() would be sufficient.
Is this behavior intended? If so, could we document it better?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels