Skip to content

Commit 39e0b78

Browse files
authored
fix(typebox): Allow nested or in and queries (#3029)
1 parent 1bac380 commit 39e0b78

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

packages/typebox/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ export const querySyntax = <
159159
options: ObjectOptions = { additionalProperties: false }
160160
) => {
161161
const propertySchema = queryProperties(type, extensions)
162+
const $or = Type.Array(propertySchema)
163+
const $and = Type.Array(Type.Union([propertySchema, Type.Object({ $or })]))
162164

163165
return Type.Intersect(
164166
[
@@ -169,8 +171,8 @@ export const querySyntax = <
169171
$skip: Type.Number({ minimum: 0 }),
170172
$sort: sortDefinition(type),
171173
$select: arrayOfKeys(type),
172-
$or: Type.Array(propertySchema),
173-
$and: Type.Array(propertySchema)
174+
$and,
175+
$or
174176
},
175177
{ additionalProperties: false }
176178
)

0 commit comments

Comments
 (0)