This is a screenshot from Compass. I don’t understand why my document has failed validation. The validator states that description is required and the document has a description of “hello”
I am not very schema validation aware but my gut feeling would be that it should be
{
"description" : "required"
}
rather than
{
"required" : "description"
}
simply because if you have many required field a basic JSON requirement of not having multiple fields with the same key will be broken if you had { required : f1 , required : f2 } rather than { f1 : required , f2 : required }.
Thanks for your reply. That didn’t work. However, I have solved it. I needed to use $jsonSchema and put the field name into a list.
{
$jsonSchema: {
required: [
'x'
]
}
}
2 Likes