When document fails validation because the number of array elements did not match (using JSON Schema maxItems/minItems), the message doesn't return the length of the considered array. This may be not convenient for large arrays, as user has to count the items in "consideredValue" to understand if the count was off by 1 or more significantly.
Meanwhile on violation of "maxProperties"/"minProperties" the error contains the number of properties.
v={ "$jsonSchema": { "properties": { "myArray": { "bsonType": "array", "maxItems": 3 } }, "maxProperties": 1 } }; db.createCollection("c", {validator: v}); db.c.insert({myArray: [1,2,3,4,5], key:"value"})
{ "failingDocumentId": ObjectId("60391cae714cc76b719698a5"), "details": { "operatorName": "$jsonSchema", "schemaRulesNotSatisfied": [ { "operatorName": "properties", "propertiesNotSatisfied": [ { "propertyName": "myArray", "details": [ { "operatorName": "maxItems", "specifiedAs": { "maxItems": 3 }, "reason": "array did not match specified length", "consideredValue": [1, 2, 3, 4, 5] } ] } ] }, { "operatorName": "minProperties", "specifiedAs": { "minProperties": 10 }, "reason": "specified number of properties was not satisfied", "numberOfProperties": 3 } ] } }