I hope it's not a misunderstanding from my part but it seemed to me that a Mixed type corresponds to an any type and my usual code using mongoose works well with that constraint.
But when I use a Schema.Types.Mixed in the type property I cannot pass an array. The server returns an error saying it expected an Object.
1|CURD-Server | [19:05:45.554] 32236 ERROR src/index.js:50:21 api — ValidationError: "value" must be an array, child "context" fails because ["context" must be an object]
1|CURD-Server | [19:05:45.554] 32236 ERROR src/index.js:50:21 api — at Object.exports.process (/prod/curd-server/node_modules/rest-hapi/node_modules/@hapi/joi/lib/errors.js:202:19)
1|CURD-Server | [19:05:45.554] 32236 ERROR src/index.js:50:21 api — at internals.Alternatives._validateWithOptions (/prod/curd-server/node_modules/rest-hapi/node_modules/@hapi/joi/lib/types/any/index.js:762:31)
1|CURD-Server | [19:05:45.554] 32236 ERROR src/index.js:50:21 api — at internals.Alternatives.validate (/prod/curd-server/node_modules/rest-hapi/node_modules/@hapi/joi/lib/types/any/index.js:796:21)
1|CURD-Server | [19:05:45.554] 32236 ERROR src/index.js:50:21 api — at Object.internals.validate (/prod/curd-server/node_modules/@hapi/hapi/lib/validation.js:224:19)
1|CURD-Server | [19:05:45.554] 32236 ERROR src/index.js:50:21 api — at Object.internals.input (/prod/curd-server/node_modules/@hapi/hapi/lib/validation.js:103:69)
1|CURD-Server | [19:05:45.554] 32236 ERROR src/index.js:50:21 api — at exports.payload (/prod/curd-server/node_modules/@hapi/hapi/lib/validation.js:63:22)
1|CURD-Server | [19:05:45.554] 32236 ERROR src/index.js:50:21 api — at Request._lifecycle (/prod/curd-server/node_modules/@hapi/hapi/lib/request.js:312:68)
1|CURD-Server | [19:05:45.554] 32236 ERROR src/index.js:50:21 api — at <anonymous>
1|CURD-Server | [19:05:45.554] 32236 ERROR src/index.js:50:21 api — at process._tickDomainCallback (internal/process/next_tick.js:228:7)
I have to pass context: { type: [{ type: Schema.Types.Mixed }] }, for it to work but that disables me to pass a single object
I hope it's not a misunderstanding from my part but it seemed to me that a
Mixed
type corresponds to anany
type and my usual code using mongoose works well with that constraint. But when I use aSchema.Types.Mixed
in thetype
property I cannot pass anarray
. The server returns an error saying it expected anObject
.I have to pass
context: { type: [{ type: Schema.Types.Mixed }] },
for it to work but that disables me to pass a single object