MCPcopy Index your code
hub / github.com/directus/directus / validateFilter

Function validateFilter

api/src/utils/validate-query.ts:64–126  ·  view source on GitHub ↗
(filter: Filter)

Source from the content-addressed store, hash-verified

62}
63
64function validateFilter(filter: Filter) {
65 for (const [key, nested] of Object.entries(filter)) {
66 if (key === '_and' || key === '_or') {
67 nested.forEach(validateFilter);
68 } else if (key.startsWith('_')) {
69 const value = nested;
70
71 switch (key) {
72 case '_in':
73 case '_nin':
74 case '_between':
75 case '_nbetween':
76 validateList(value, key);
77 break;
78 case '_null':
79 case '_nnull':
80 case '_empty':
81 case '_nempty':
82 validateBoolean(value, key);
83 break;
84 case '_intersects':
85 case '_nintersects':
86 case '_intersects_bbox':
87 case '_nintersects_bbox':
88 validateGeometry(value, key);
89 break;
90 case '_json':
91 validateJsonFilter(value);
92 break;
93 case '_none':
94 case '_some':
95 validateFilter(nested);
96 break;
97 case '_eq':
98 case '_neq':
99 case '_contains':
100 case '_ncontains':
101 case '_starts_with':
102 case '_nstarts_with':
103 case '_istarts_with':
104 case '_nistarts_with':
105 case '_ends_with':
106 case '_nends_with':
107 case '_iends_with':
108 case '_niends_with':
109 case '_gt':
110 case '_gte':
111 case '_lt':
112 case '_lte':
113 default:
114 validateFilterPrimitive(value, key);
115 break;
116 }
117 } else if (isPlainObject(nested)) {
118 validateFilter(nested);
119 } else if (Array.isArray(nested) === false) {
120 validateFilterPrimitive(nested, '_eq');
121 } else {

Callers 2

validateQueryFunction · 0.85
validateJsonFilterFunction · 0.85

Calls 5

validateListFunction · 0.85
validateBooleanFunction · 0.85
validateGeometryFunction · 0.85
validateJsonFilterFunction · 0.85
validateFilterPrimitiveFunction · 0.85

Tested by

no test coverage detected