From fc334391b53d9664a79946c36707c266aafd79e1 Mon Sep 17 00:00:00 2001 From: scarf Date: Thu, 6 Jul 2023 20:31:40 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20review=20=EC=8A=A4=ED=82=A4=EB=A7=88=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=20=EA=B2=80=EC=A6=9D=20=EC=99=84=ED=99=94,?= =?UTF-8?q?=20=20disabled=20=ED=95=84=EB=93=9C=20=EA=B8=B0=EB=B3=B8?= =?UTF-8?q?=EA=B0=92=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/reviews/controller/reviews.type.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/backend/src/reviews/controller/reviews.type.ts b/backend/src/reviews/controller/reviews.type.ts index 721502ee..c2c5ab9b 100644 --- a/backend/src/reviews/controller/reviews.type.ts +++ b/backend/src/reviews/controller/reviews.type.ts @@ -21,7 +21,7 @@ type Disabled = 0 | 1 | -1; const disabledSchema = z.coerce.number().int().refine( (n): n is Disabled => [-1, 0, 1].includes(n), (n) => ({ message: `0: 공개, 1: 비공개, -1: 전체 리뷰, 입력값: ${n}` }), -); +).default(-1); export const queryOptionSchema = z.object({ page: positiveInt.default(0), @@ -29,8 +29,15 @@ export const queryOptionSchema = z.object({ sort: sortSchema, }); +export const booleanLikeSchema = z.union([ + z.boolean(), + z.string().toLowerCase() + .refine((s) => s === 'true' || s === 'false') + .transform((s) => s === 'true'), +]); + export const getReviewsSchema = z.object({ - isMyReview: z.boolean().default(false), + isMyReview: booleanLikeSchema.catch(false), titleOrNickname: z.string().optional(), disabled: disabledSchema, }).merge(queryOptionSchema);