开发者

An optional dict in the structure with MongoKit

开发者 https://www.devze.com 2023-01-10 19:37 出处:网络
I\'ve got MongoKit structure like th开发者_运维技巧is: structure = { ... \'plugin\': { \'id\': unicode,

I've got MongoKit structure like th开发者_运维技巧is:

structure = {
  ...

  'plugin': {
    'id': unicode,
    'title': unicode,
    'description': unicode,

  ...
}

However, not all documents will have the plugin key. If they do, I'd like it to be validated against the structure.

required_fields does not include plugin. (plugin isn't a required key.)

I've tried 'plugin': OR(None, {...}), but OR doesn't like None as a value.

Any ideas?


Looks like a bug in 0.5:

http://bitbucket.org/namlook/mongokit/issue/78/not-required-fields-wrongly-validates#comment-234872

Discussion and temporary workaround here:

http://groups.google.com/group/mongokit/browse_thread/thread/18fe4081a306e93e

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号