fix(filters): validate external filters (#1250)

* fix(filters): Set webhook method default to POST

* fix: details.tsx

* feat(filters): validate external filters

---------

Co-authored-by: ze0s <43699394+zze0s@users.noreply.github.com>
This commit is contained in:
soup 2023-11-19 21:32:09 +01:00 committed by GitHub
parent f35d10d7c0
commit 70a2f2d713
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -223,6 +223,48 @@ const externalFilterSchema = z.object({
webhook_retry_status: z.string().optional(),
webhook_retry_attempts: z.number().optional(),
webhook_retry_delay_seconds: z.number().optional(),
}).superRefine((value, ctx) => {
if (!value.name) {
ctx.addIssue({
message: "Must have a name",
code: z.ZodIssueCode.custom,
path: ["name"]
});
}
if (value.type == "WEBHOOK") {
if (!value.webhook_method) {
ctx.addIssue({
message: "Must select method",
code: z.ZodIssueCode.custom,
path: ["webhook_method"]
});
}
if (!value.webhook_host) {
ctx.addIssue({
message: "Must have webhook host",
code: z.ZodIssueCode.custom,
path: ["webhook_host"]
});
}
if (!value.webhook_expect_status) {
ctx.addIssue({
message: "Must have webhook expect status",
code: z.ZodIssueCode.custom,
path: ["webhook_expect_status"]
});
}
}
if (value.type == "EXEC") {
if (!value.exec_cmd) {
ctx.addIssue({
message: "Must have exec cmd",
code: z.ZodIssueCode.custom,
path: ["exec_cmd"]
});
}
}
});
const indexerSchema = z.object({