Document would fail validation

“Document would fail validation” is not a very helpful error message.
I’ve looked in the log and there is no more information there.
I have tried to eyeball my validation schema and I see no errors (though there must be one!).
How do I debug failed validation, please?

Do validation rules imply an order to the members of the document when they are insterted?

If you share your document that fails your schema and your schema, we could help better.

I’m not terribly eager to share that. I was just wondering if I am missing tools or error level settings that would make it easier to find the problem.

No problem.

I personally avoid schema validation because one thing I like about MongoDB is the schema less document storage. I fully unit test all my code so having a schema validation is more a hurdle than an help.

Have fun and a good day.

@steevej I’m new to MongoDB and was exploring how far a collection can be made rigorous.

I wasn’t really looking for someone to fix my problem, more like, point me to what tools I should be using or what config factors would make MongoDB identify for me the problem field that is causing the validation error.

It seems so elementary a requirement that it’s hard to believe such a feature does not exist.

Apparently there is no such feature, but 4.6 will have it.

Hi @Jack_Woehr,

Have you tried MongoDB Compass?
There is a tab for validation.


Yes, @MaBeuLux88, the problem is not validation itself but debugging why validation has failed.
There is simply no user facility in MongoDB to help determine the cause of validation failure.