I'm attempting to construct a recursive schema using cerberus but appear to be missing the point of how it should work. Could someone help me out?
In the documentation and old issues in the repo it is explained that the way to handle recursion is to use schema registries to create self-referencing schema, otherwise we hit recursion depth limits.
However, trying something very basic leads to a TypeError.
It would be great to get a schema recursion example in the docs please! I'd be happy to help submit one once I understand what is going on.
cerberus.schema_registry.add(
'user_schema',
{
'uid': {
'type': 'integer'
},
'next': {
'type': 'list',
'schema': 'user_schema'
}
}
)
schema = {'sender': {'schema': 'user_schema'}}
v = cerberus.Validator(schema=schema)
v.validate({
'sender': {
'uid': 1,
'next': [
{
'uid': 1,
}
]
}
})
Running the above leads to the following unhandled exception:
TypeError: argument of type 'NoneType' is not iterable
Help would be very much appreciated!