From 2e22978838b6ce16bb038a0acefbcf94a9910089 Mon Sep 17 00:00:00 2001 From: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> Date: Wed, 25 May 2022 14:23:43 +0530 Subject: [PATCH] Added schema for create --- lib/validations/webhook.ts | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/lib/validations/webhook.ts b/lib/validations/webhook.ts index aab40dc502..a655e5f11c 100644 --- a/lib/validations/webhook.ts +++ b/lib/validations/webhook.ts @@ -12,29 +12,21 @@ const schemaWebhookBaseBodyParams = Webhook.pick({ payloadTemplate: true, }).partial(); -// const schemaWebhookCreateParams = z -// .object({ -// id: z.string(), -// subscriberUrl: z.string(), -// }) -// .strict(); +export const schemaWebhookCreateParams = z + .object({ + userId: z.number().or(z.string()).optional(), + eventTypeId: z.number().or(z.string()).optional(), + eventTriggers: z.any.optional(), + active: z.boolean().optional(), + subscriberUrl: z.string(), + payloadTemplate: z.string().optional(), + }) + .strict(); export const schemaWebhookCreateBodyParams = schemaWebhookBaseBodyParams.merge( - z.object({ - id: z.string(), - subscriberUrl: z.string(), - }) + schemaWebhookCreateParams ); -// const schemaWebhookEditParams = z -// .object({ -// payloadTemplate: z.string().optional(), -// /** @todo: don't use any here and validate eventTriggers proper */ -// eventTriggers: z.any(), -// subscriberUrl: z.string().optional(), -// }) -// .strict(); - export const schemaWebhookEditBodyParams = schemaWebhookBaseBodyParams.merge( z.object({ payloadTemplate: z.string().optional(),