[COMPASS-950] Allow users to specify array validation that applies to all array elements Created: 24/Mar/17  Updated: 27/Oct/23  Resolved: 14/Nov/18

Status: Closed
Project: Compass
Component/s: Document Validation
Affects Version/s: None
Fix Version/s: 1.18.0

Type: Task Priority: Major - P3
Reporter: Brian Blevins Assignee: Unassigned
Resolution: Gone away Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: COMPASS-2227

 Description   

General

According to:
https://jira.mongodb.org/browse/SERVER-27902
it is possible to validate all entries in an array for some criteria.

This feature request is to allow Compass users to specify which validation rules apply to arrays so that the $elemMatch plus $not matching from SERVER-27902 can be used to implement the users' expectation of validation over all elements of the array subdocument.

Intercom conversation on the topic:
https://app.intercom.io/a/apps/p57suhg7/users/58cdcb88d9d8a5b427c0b15f

Considerations

Applying the $elemMatch plus $not pattern at the leaf node of the document field specification ("field.subfield.subsubfield.leafsubsubsubfield") would be relatively straightforward. Just add another column similar to "Nullable". However, for the general case, the pattern would need to be available for an array present at any of the subfield levels. It is unclear how that kind of flexibility could be simply and intuitively represented to the user in the UI.



 Comments   
Comment by Asya Kamsky [ 24/Sep/17 ]

Probably better to validate all array elements via new $jsonSchema support in 3.6 which should be supported by Compass once it's available.

Currently it doesn't appear like complex $or and $and patterns are supported, and it's likely those would be necessary along with $elemMatch.

Generated at Wed Feb 07 22:26:26 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.