Skip to content

Commit 9bb851f

Browse files
committed
fix: default responses to empty array
1 parent 495c927 commit 9bb851f

File tree

1 file changed

+14
-12
lines changed
  • packages/backend/src/apps/paysg/actions/create-payment-form-submission

1 file changed

+14
-12
lines changed

packages/backend/src/apps/paysg/actions/create-payment-form-submission/schema.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,18 @@ export const requestSchema = z.object({
8383
.max(500, { message: 'Description cannot be more than 500 characters' })
8484
.transform((value) => value || undefined)
8585
.optional(),
86-
responses: z.array(
87-
z.object({
88-
question: z
89-
.string({ invalid_type_error: 'Empty question' })
90-
.trim()
91-
.min(1, { message: 'Empty question' }),
92-
answer: z
93-
.string({ invalid_type_error: 'Empty answer' })
94-
.trim()
95-
.min(1, { message: 'Empty answer' }),
96-
}),
97-
),
86+
responses: z
87+
.array(
88+
z.object({
89+
question: z
90+
.string({ invalid_type_error: 'Empty question' })
91+
.trim()
92+
.min(1, { message: 'Empty question' }),
93+
answer: z
94+
.string({ invalid_type_error: 'Empty answer' })
95+
.trim()
96+
.min(1, { message: 'Empty answer' }),
97+
}),
98+
)
99+
.default([]),
98100
})

0 commit comments

Comments
 (0)