[SERVER-24846] disallow extra fields when validating documents Created: 30/Jun/16 Updated: 06/Dec/22 Resolved: 24/Mar/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Storage |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Ciprian Trusca | Assignee: | Backlog - Query Team (Inactive) |
| Resolution: | Duplicate | Votes: | 4 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Assigned Teams: |
Query
|
||||||||||||
| Participants: | |||||||||||||
| Description |
|
I would like to be able to validate the documents so that no extra fields, beyond the ones already declared. For example if i have a schema like this :
I would like the following document to fail:
|
| Comments |
| Comment by Asya Kamsky [ 24/Mar/18 ] |
|
Available via $jsonSchema as of 3.6.0. |
| Comment by Asya Kamsky [ 24/Mar/18 ] |
|
This was enabled via |
| Comment by Asya Kamsky [ 28/Nov/16 ] |
|
kkumarc@gmail.com this ticket is tracking the ability to disallow any new fields (ones that are not explicitly allowed) from being inserted. The only way I can see it being useful for your use case is if you set validationAction to "warn" and then grep the logs for fields not in the validator document. |
| Comment by KRISHNA KUMAR [ 23/Nov/16 ] |
|
Hi, regards |
| Comment by Kelsey Schubert [ 02/Sep/16 ] |
|
Hi hbalint, Thank you for your interest in contributing to MongoDB. Please be aware that we have recently entered our stabilization period in preparation for the release of MongoDB 3.4. We our doing our best to freeze new feature development in order to focus on quality and performance, and to ensure that downstream work (such as that required for the documentation and drivers) can be completed. We haven't had a chance yet to discuss this improvement request, and will update this ticket when we have a better idea of how this functionality can be best implemented and whether it is something we want to incorporate into the product at this time. My recommendation would be to wait for additional input before beginning work on a patch. In the meantime, you can take the first step of signing the contributor agreement. Kind regards, |
| Comment by Bálint Horváth [ 02/Sep/16 ] |
|
Hi guys, I'm also really interested in it and its future possibilities and I'm considering contribution... Unfortunately I can't see the private comments. Is there any news or an alternate issue about it or this is the primary one? Is there any concept/plan for it? Any other links to other discussions maybe? In my opinion, document shouldn't fail by default even if validator is defined but option would be very useful to define allowed fields (mostly because of multi-level documents which makes more difficult to do validation on higher level than MongoDB with proper security and performance). (Currently I'm designing a system which is partly relies on the mongo validator. Already a really cool feature.) Thanks, |
| Comment by Ramon Fernandez Marina [ 30/Jun/16 ] |
|
Thanks for your report cip123; I was convinced this functionality had been requested already, but I can't seem to find the ticket so I'm sending this to the Integration team for consideration. Regards, |