mirror of
https://github.com/idanoo/autobrr
synced 2025-07-22 16:29:12 +00:00
feat(filters): add validation for max downloads unit (#1618)
This commit is contained in:
parent
e8e45c664d
commit
4b884ee859
1 changed files with 12 additions and 0 deletions
|
@ -286,9 +286,21 @@ const indexerSchema = z.object({
|
||||||
// Define the schema for the entire object
|
// Define the schema for the entire object
|
||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
name: z.string(),
|
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" }),
|
indexers: z.array(indexerSchema).min(1, { message: "Must select at least one indexer" }),
|
||||||
actions: z.array(actionSchema),
|
actions: z.array(actionSchema),
|
||||||
external: z.array(externalFilterSchema)
|
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 = () => {
|
export const FilterDetails = () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue