Skip to content

Commit 933788c

Browse files
authored
Merge pull request #7 from devforth/next
Next
2 parents bb9732c + 3f35475 commit 933788c

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

index.ts

+1-19
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,11 @@ export default class ImportExport extends AdminForthPlugin {
5757
handler: async ({ body }) => {
5858
const { filters, sort } = body;
5959

60-
for (const filter of (filters || [])) {
61-
if (!Object.values(AdminForthFilterOperators).includes(filter.operator)) {
62-
throw new Error(`Operator '${filter.operator}' is not allowed`);
63-
}
64-
if (!this.resourceConfig.columns.some((col) => col.name === filter.field)) {
65-
throw new Error(`Field '${filter.field}' is not in resource '${this.resourceConfig.resourceId}'. Available fields: ${this.resourceConfig.columns.map((col) => col.name).join(', ')}`);
66-
}
67-
if (filter.operator === AdminForthFilterOperators.IN || filter.operator === AdminForthFilterOperators.NIN) {
68-
if (!Array.isArray(filter.value)) {
69-
throw new Error(`Value for operator '${filter.operator}' should be an array`);
70-
}
71-
}
72-
if (filter.operator === AdminForthFilterOperators.IN && filter.value.length === 0) {
73-
// nonsense
74-
return { data: [], total: 0 };
75-
}
76-
}
77-
7860
const data = await this.adminforth.connectors[this.resourceConfig.dataSource].getData({
7961
resource: this.resourceConfig,
8062
limit: 1e6,
8163
offset: 0,
82-
filters,
64+
filters: this.adminforth.connectors[this.resourceConfig.dataSource].validateAndNormalizeInputFilters(filters),
8365
sort,
8466
getTotals: true,
8567
});

0 commit comments

Comments
 (0)