alecthomas / voluptuous

CONTRIBUTIONS ONLY: Voluptuous, despite the name, is a Python data validation library.
https://pypi.org/project/voluptuous
BSD 3-Clause "New" or "Revised" License
1.82k stars 218 forks source link

Schema extends a list of dict objects #376

Closed 3dw1np closed 5 years ago

3dw1np commented 5 years ago

I am trying to extend a nested schema definition inside a list:

`

t = Schema({ ... 'delivery_addresses': All([{ ... Required('name'): unicode ... }]) ... })

t = t.extend({ ... Required('delivery_addresses'): [{ ... Required('geohash'): unicode ... }] ... })

print(t) {u'delivery_addresses': [{u'geohash': <type 'unicode'>}]} `

But as you can see, it's not merging the dict definition, it's replacing.

alecthomas commented 5 years ago

You can only replace or add keys.