-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Recently I encountered a problem with JSONAlchemy config (.cfg) files. I wanted to create a field which should be a list of strings inside the record. Here is the definition:
schema:
{'emails': {'type': 'list', 'force': True, 'schema': {'type': 'string'}}}When there is no key emails in the dictionary handled to Record.create method, I obtain:
>>> rec['emails']
[{'type': None}]It seems that JSONAlchemy always understands schema as a base for a dictionary. Other than that, it works fine.
I can make it working by defining the field as:
schema:
{'emails': {'type': 'list', 'force': True, 'items': {'type': 'string'}}}But in this case I can't pass the validation, as Cerberus expects dictionaries inside the list.
https://cerberus.readthedocs.org/en/latest/#items-list
https://cerberus.readthedocs.org/en/latest/#schema-list
Please note that Cerberus' documentation is not complete.
What to do?