I'm relatively new to mongo and I'm encountering a validation issue in our production environment that doesn't appear to be happening in our dev environment.
I think this is due to the validationLevel not being set to strict in dev.
I've lost hours on this now so thought I'd reach out to see if we have any mongo experts that can help me out.
Below is the jsonSchema for our collection and the document that is failing validation.
Does anyone have any idea why validation is failing. Stupidly mongo doesn't give any useful error messages.
{
"validator" : {
"$jsonSchema" : {
"bsonType" : "object",
"required" : [
"name",
"subdomain",
"userLimit",
"isTrial",
"trialExpiryDate"
],
"properties" : {
"name" : {
"bsonType" : "string"
},
"subdomain" : {
"bsonType" : "string"
},
"userLimit" : {
"bsonType" : "int"
},
"isTrial" : {
"bsonType" : "bool"
},
"trialExpiryDate" : {
"bsonType" : "date"
},
"viewDisplayOrders": {
"bsonType" : "array"
}
}
}
},
"validationLevel" : "strict",
"validationAction" : "error"}
{
"_id" : ObjectId("5cc71aae77a8801149aab04d"),
"name" : "Mushroom Kingdom",
"subdomain" : "mushroom-kingdom",
"viewDisplayOrders" : [
{
"_id" : "5cc72902e2d2f112be40c937",
"displayOrder" : 0
},
{
"_id" : "5cc72dd5e2d2f112be40c96c",
"displayOrder" : 1
},
{
"_id" : "5cc74fbfe2d2f112be40ccba",
"displayOrder" : 2
},
{
"_id" : "5cc75658e2d2f112be40cf78",
"displayOrder" : 3
},
{
"_id" : "5cc720b148ba7011394abcbf",
"displayOrder" : 4
},
{
"_id" : "5cc8c32a5c62ac1ea3dd3d5b",
"displayOrder" : 5
}
],
"isTrial" : true,
"userLimit" : 10,
"trialExpiryDate" : ISODate("2019-05-28T00:00:00Z")
}