(query: Query)
| 38 | }).id('query'); |
| 39 | |
| 40 | export function validateQuery(query: Query): Query { |
| 41 | const { error } = querySchema.validate(query); |
| 42 | |
| 43 | if (query.filter && Object.keys(query.filter).length > 0) { |
| 44 | validateFilter(query.filter); |
| 45 | } |
| 46 | |
| 47 | if (query.alias) { |
| 48 | validateAlias(query.alias); |
| 49 | } |
| 50 | |
| 51 | if (query.sort) { |
| 52 | validateSort(query.sort); |
| 53 | } |
| 54 | |
| 55 | validateRelationalDepth(query); |
| 56 | |
| 57 | if (error) { |
| 58 | throw new InvalidQueryError({ reason: error.message }); |
| 59 | } |
| 60 | |
| 61 | return query; |
| 62 | } |
| 63 | |
| 64 | function validateFilter(filter: Filter) { |
| 65 | for (const [key, nested] of Object.entries(filter)) { |
no test coverage detected