Skip to content

Commit

Permalink
fix(typebox): Allow nested or in and queries (#3029)
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl authored Feb 1, 2023
1 parent 1bac380 commit 39e0b78
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/typebox/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ export const querySyntax = <
options: ObjectOptions = { additionalProperties: false }
) => {
const propertySchema = queryProperties(type, extensions)
const $or = Type.Array(propertySchema)
const $and = Type.Array(Type.Union([propertySchema, Type.Object({ $or })]))

return Type.Intersect(
[
Expand All @@ -169,8 +171,8 @@ export const querySyntax = <
$skip: Type.Number({ minimum: 0 }),
$sort: sortDefinition(type),
$select: arrayOfKeys(type),
$or: Type.Array(propertySchema),
$and: Type.Array(propertySchema)
$and,
$or
},
{ additionalProperties: false }
)
Expand Down

0 comments on commit 39e0b78

Please sign in to comment.