MCPcopy
hub / github.com/directus/directus / validateQuery

Function validateQuery

api/src/utils/validate-query.ts:40–62  ·  view source on GitHub ↗
(query: Query)

Source from the content-addressed store, hash-verified

38}).id('query');
39
40export 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
64function validateFilter(filter: Filter) {
65 for (const [key, nested] of Object.entries(filter)) {

Callers 3

sanitizeQueryMiddlewareFunction · 0.50
validateBatchFunction · 0.50

Calls 4

validateFilterFunction · 0.85
validateAliasFunction · 0.85
validateSortFunction · 0.85
validateRelationalDepthFunction · 0.85

Tested by

no test coverage detected