Skip to content

$in query throws validation error #3341

Answered by ericuldall
ericuldall asked this question in Q&A
Discussion options

You must be logged in to vote

The fix:

// Schema for allowed query properties
const listTypeFixes = Type.Optional(Type.Union([
  ObjectIdSchema(),
  Type.Array(ObjectIdSchema()),
  Type.Object({ $nin: Type.Array(ObjectIdSchema()) }),
  Type.Object({ $in: Type.Array(ObjectIdSchema()) }),
]));
export const myServiceQueryProperties = Type.Pick(myServiceSchema, ['lists'])
export const myServiceQuerySchema = Type.Intersect(
  [
    querySyntax(myServiceQueryProperties),
    // ADD FIX HERE
    Type.Object({
      lists: listTypeFixes,
      $and: Type.Array(Type.Object({ // i'm using an $and for some so I added this too
        lists: listTypeFixes
      }))
    }, { additionalProperties: false })
  ],
  { additionalProper…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@ericuldall
Comment options

@ericuldall
Comment options

@daffl
Comment options

@ericuldall
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by ericuldall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants