0

I need to validate Python dicts that will have arbitrary names. When I attempt to validate them using Cerberus, I get unknown field. Is there a way of allowing for arbitrary dict names?

I was thinking that keysrules might work, but it appears to only work on items within the base dict.

{'account_created': {'category': 'Accounts',
                     'conversion_event': True,
                     'description': 'A new account is created'}
}

I would like to be able to use an arbitrary name where account_created is in this dict.

4

1 回答 1

0

假设您不需要验证该基本密钥,我只是尝试在Cerberus GitHub上回答与此类似的问题。我的建议是也许使用动态形成的模式。您可以关注 GitHub 问题线程,看看是否有人提出了更好的答案。

于 2019-07-04T05:48:12.800 回答