fix: apply feedback

This commit is contained in:
abdou6666 2025-02-04 16:13:14 +01:00
parent abb90fcd12
commit ccd8d95f8f

View File

@ -348,8 +348,23 @@ const quickReplySchema = z
} }
}); });
// pluginBlockMessageObjectSchema in case of plugin
export const pluginBlockMessageObjectSchema = z
.record(z.any())
.superRefine((data, ctx) => {
if (!('plugin' in data)) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "The object must contain the 'plugin' attribute",
path: ['plugin'],
});
}
});
// BlockMessage Schema // BlockMessage Schema
export const blockMessageObjectSchema = z.object({ export const blockMessageObjectSchema = z.union([
pluginBlockMessageObjectSchema,
z.object({
text: z.string().max(1000).optional(), text: z.string().max(1000).optional(),
attachment: z attachment: z
.object({ .object({
@ -371,4 +386,5 @@ export const blockMessageObjectSchema = z.object({
.optional(), .optional(),
buttons: z.array(buttonSchema).max(3).optional(), buttons: z.array(buttonSchema).max(3).optional(),
quickReplies: z.array(quickReplySchema).max(11).optional(), quickReplies: z.array(quickReplySchema).max(11).optional(),
}); }),
]);