-
-
Notifications
You must be signed in to change notification settings - Fork 595
Description
When working with mongodb the database can enforce document structure with jsonSchema according to [1].
However mongodb has some own datatypes [2], like ObjectId, Date, Bool, Int that are not supported natively by json schema. These can be encoded by using the extension "bsonType" property instead of "type".
It would be very useful if jsonschema could validate such objects also. When a document fails validation inside mongodb you don't get any explanation why [3], so you always have to validate it with another validator client-side on failed insertions. Right now there is no such validator for python so the best workaround is to remove all bsonTypes before using jsonschema or convert the document into nodejs and use ajv. Neither option is really smooth.
[1] https://docs.mongodb.com/manual/reference/operator/query/jsonSchema/#jsonschema-extension
[2] https://docs.mongodb.com/manual/reference/operator/query/type/#document-type-available-types
[3] https://jira.mongodb.org/browse/SERVER-20547