Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Allow for missing values #60
Chris, sorry I did not get back to you on this. It was a weird week and my inbox is kind of piled up. The issue was that missing= is really treated as a default=, meaning that if the value is not provided, then a default is provided. My feeling is that it would be really useful to actually allow for missing values which do not have a default. The primary use case I have is in validating schema for NoSQL or similar solutions where you don't want empty values cluttering up the data. To do this, I am defaulting to None, and then just popping the keys with None values before pushing into a MongoDB.
This is inconvenient but it works. I think this really goes in the category of design choice more than bug.
Ah, right! I'l reopen this. It's a reasonable feature request (albeit one we might not be able to get around to in any predictable amount of time). I might suggest something like "missing=colander.drop" for child nodes of sequences and mappings. If subnode of a sequence or mapping deserializes to "colander.drop", the container implementation would just omit it from the deserialization value.
This comment has been minimized.
This comment has been minimized.Show comment Hide comment
Say you've implemented
Here be example:
The idea is to make this schema works normally as it currently does, and provides a switch to make all nodes droppable when missing.
So it will be like this:
Note: maybe raising invalid if all nodes are missing? Another kwarg?
This way, we can use the same schema on both creating and updating an object.
Is this a good idea? Thoughts?