feat: add validation to widget edit modal inputs (#879)

* feat: add validation to widget edit modal inputs

* chore: remove unused console.log statements
This commit is contained in:
Meier Lukas
2024-07-28 19:38:19 +02:00
committed by GitHub
parent 851f5e486d
commit 9cb6200895
5 changed files with 74 additions and 43 deletions

View File

@@ -1,6 +1,7 @@
import { objectEntries } from "@homarr/common";
import type { WidgetKind } from "@homarr/definitions";
import type { z, ZodType } from "@homarr/validation";
import type { ZodType } from "@homarr/validation";
import { z } from "@homarr/validation";
import { widgetImports } from ".";
import type { inferSelectOptionValue, SelectOption } from "./_inputs/widget-select-input";
@@ -90,6 +91,11 @@ const optionsFactory = {
longitude: 0,
},
withDescription: input?.withDescription ?? false,
validate: z.object({
name: z.string().min(1),
latitude: z.number(),
longitude: z.number(),
}),
}),
multiText: (input?: CommonInput<string[]> & { validate?: ZodType }) => ({
type: "multiText" as const,