feat(filters): add validation for max downloads unit (#1618)

This commit is contained in:
ze0s 2024-08-13 20:45:12 +02:00 committed by GitHub
parent e8e45c664d
commit 4b884ee859
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -286,9 +286,21 @@ const indexerSchema = z.object({
// Define the schema for the entire object
const schema = z.object({
name: z.string(),
max_downloads: z.number().optional(),
max_downloads_unit: z.string().optional(),
indexers: z.array(indexerSchema).min(1, { message: "Must select at least one indexer" }),
actions: z.array(actionSchema),
external: z.array(externalFilterSchema)
}).superRefine((value, ctx) => {
if (value.max_downloads && value.max_downloads > 0) {
if (!value.max_downloads_unit) {
ctx.addIssue({
message: "Must select Max Downloads Per unit when Max Downloads is greater than 0",
code: z.ZodIssueCode.custom,
path: ["max_downloads_unit"]
});
}
}
});
export const FilterDetails = () => {