[SERVER-23912] validator can not validate array. Created: 25/Apr/16 Updated: 26/Apr/16 Resolved: 25/Apr/16 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Storage |
| Affects Version/s: | 3.2.5 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | tetsutaro watanabe | Assignee: | Kelsey Schubert |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL |
| Participants: |
| Description |
|
Hi. I try to validate arry. But it does not work. First I make collection with validator.
|
| Comments |
| Comment by tetsutaro watanabe [ 26/Apr/16 ] | ||||||||||
|
Hi Thomas, Thank you ! I will use the workaround. | ||||||||||
| Comment by Kelsey Schubert [ 25/Apr/16 ] | ||||||||||
|
Hi fetaro@gmail.com, The behavior you describe is expected. As documented here, MongoDB evaluates the type of each element in the array. Since none of the elements in the array are arrays the validator rejects the document. I've included an example showing the same behavior using queries.
As a workaround please consider using the following validator:
I expect that this validator will fit your use case, assuming that you do not intend to insert empty arrays or objects with a field name of "0". Kind regards, |