I don’t seem to get schema validation erros as output, just something like this:
"validateOutput": {
"ns": "21risk.sessions",
"nInvalidDocuments": 0,
"nrecords": 181856,
"nIndexes": 2,
"keysPerIndex": {
"_id_": 181856,
"expires_1": 181856
},
"indexDetails": {
"_id_": {
"valid": true
},
"expires_1": {
"valid": true
}
},
"valid": true,
"repaired": false,
"warnings": [],
"errors": [],
"extraIndexEntries": [],
"missingIndexEntries": [],
"corruptRecords": [],
"ok": 1,
"$clusterTime": {
"clusterTime": {
"$timestamp": "7125046445631078401"
},
"signature": {
"hash": "Kq8B4EiRRx5Q7A7Wk1faUpcRfUk=",
"keyId": {
"low": 2,
"high": 1646856462,
"unsigned": false
}
}
},
"operationTime": {
"$timestamp": "7125046445631078401"
}
}
With the node.js driver, I call the validate like this validateOutput = await db.admin().validateCollection(col.name);
But I don’t seem to have an option for setting full: true
- as described in the docs here.
Workaround:
Currently I simply validate the schema with ajv:
import Ajv from 'ajv';
const ajv = new Ajv({ strict: false });
const validate = ajv.compile(validator.$jsonSchema);
const result = validate(failedDoc);
if (!result) {
docSchemaErrors = validate.errors;
}
@Stennie Just tagging you, because I can see in my forum searches that you seem to be the schema validation expert
And my AJV workaround does not seem to work well in edge cases