strict only on filter and branches

This commit is contained in:
timonrieger
2026-07-26 17:15:58 +02:00
parent 8a64a3e008
commit 3f47728463
3 changed files with 4 additions and 15 deletions
-4
View File
@@ -20717,7 +20717,6 @@
"type": "object"
},
"MetadataSearchDto": {
"additionalProperties": false,
"properties": {
"albumIds": {
"deprecated": true,
@@ -23152,7 +23151,6 @@
"type": "object"
},
"RandomSearchDto": {
"additionalProperties": false,
"properties": {
"albumIds": {
"deprecated": true,
@@ -25341,7 +25339,6 @@
"type": "object"
},
"SmartSearchDto": {
"additionalProperties": false,
"properties": {
"albumIds": {
"deprecated": true,
@@ -26090,7 +26087,6 @@
"type": "object"
},
"StatisticsSearchDto": {
"additionalProperties": false,
"properties": {
"albumIds": {
"deprecated": true,
@@ -130,13 +130,6 @@ describe(SearchController.name, () => {
);
});
it('should reject an unknown field on the request body', async () => {
const { status, body } = await request(ctx.getHttpServer())
.post('/search/metadata')
.send({ filter: {}, oderBy: { field: 'rating' } });
expect(status).toBe(400);
expect(body).toEqual(errorDto.validationError([{ path: [], message: 'Unrecognized key: "oderBy"' }]));
});
it('should reject an unknown key in the filter', async () => {
const { status, body } = await request(ctx.getHttpServer())
+4 -4
View File
@@ -353,7 +353,7 @@ const RandomSearchBaseSchema = BaseSearchWithResultsSchema.extend({
filter: filterField,
});
const RandomSearchSchema = withShapeExclusivity(RandomSearchBaseSchema.strict()).meta({ id: 'RandomSearchDto' });
const RandomSearchSchema = withShapeExclusivity(RandomSearchBaseSchema).meta({ id: 'RandomSearchDto' });
const MetadataSearchSchema = withShapeExclusivity(
RandomSearchBaseSchema.extend({
@@ -369,14 +369,14 @@ const MetadataSearchSchema = withShapeExclusivity(
page: z.int().min(1).optional().describe('Page number').meta(DEPRECATED_FLAT_FIELD),
orderBy: SearchOrderSchema.optional().meta(ADDED_V3_1),
cursor: cursorField,
}).strict(),
}),
).meta({ id: 'MetadataSearchDto' });
const StatisticsSearchSchema = withShapeExclusivity(
BaseSearchSchema.extend({
description: z.string().trim().optional().describe('Filter by description text').meta(DEPRECATED_FLAT_FIELD),
filter: filterField,
}).strict(),
}),
).meta({ id: 'StatisticsSearchDto' });
const SmartSearchSchema = withShapeExclusivity(
@@ -387,7 +387,7 @@ const SmartSearchSchema = withShapeExclusivity(
language: z.string().optional().describe('Search language code'),
page: z.int().min(1).optional().describe('Page number').meta(DEPRECATED_FLAT_FIELD),
filter: filterField,
}).strict(),
}),
).meta({ id: 'SmartSearchDto' });
export class RandomSearchDto extends createZodDto(RandomSearchSchema) {}