fix(server): require at least one field to be set when updating memory (#27842)

* add zod util to require one field is set in some schemas. appy to update memory endpoint

* add test
This commit is contained in:
Freddie Floydd
2026-04-17 21:18:48 +01:00
committed by GitHub
parent 9d33853544
commit 6798d5df32
3 changed files with 28 additions and 8 deletions
+6 -8
View File
@@ -4,7 +4,7 @@ import { HistoryBuilder } from 'src/decorators';
import { AssetResponseSchema, mapAsset } from 'src/dtos/asset-response.dto';
import { AuthDto } from 'src/dtos/auth.dto';
import { AssetOrderWithRandomSchema, MemoryType, MemoryTypeSchema } from 'src/enum';
import { isoDatetimeToDate, stringToBool } from 'src/validation';
import { isoDatetimeToDate, nonEmptyPartial, stringToBool } from 'src/validation';
import z from 'zod';
const MemorySearchSchema = z
@@ -26,13 +26,11 @@ const OnThisDaySchema = z
type MemoryData = z.infer<typeof OnThisDaySchema>;
const MemoryUpdateSchema = z
.object({
isSaved: z.boolean().optional().describe('Is memory saved'),
seenAt: isoDatetimeToDate.optional().describe('Date when memory was seen'),
memoryAt: isoDatetimeToDate.optional().describe('Memory date'),
})
.meta({ id: 'MemoryUpdateDto' });
const MemoryUpdateSchema = nonEmptyPartial({
isSaved: z.boolean().describe('Is memory saved'),
seenAt: isoDatetimeToDate.describe('Date when memory was seen'),
memoryAt: isoDatetimeToDate.describe('Memory date'),
}).meta({ id: 'MemoryUpdateDto' });
const MemoryCreateSchema = z
.object({