Say I have a simple schema:
class MySchema(colander.MappingSchema):
thing = colander.SchemaNode(colander.Int())
With the schema above, when trying to deserialize {'thing': None}
I get the error:
Invalid: {'thing': u'Required'}
It looks like colander treats fields with a None
value the same way as missing fields. How can I get around that and enforce that thing
is always provided, but allow it to be None
?
A None value will work for deserialization, however you need to supply a 'missing' argument in your schema:
http://docs.pylonsproject.org/projects/colander/en/latest/null.html#deserializing-the-null-value