fix: app url not required (#2130)
This commit is contained in:
@@ -25,11 +25,11 @@ export const AppForm = (props: AppFormProps) => {
|
|||||||
const t = useI18n();
|
const t = useI18n();
|
||||||
|
|
||||||
const form = useZodForm(validation.app.manage, {
|
const form = useZodForm(validation.app.manage, {
|
||||||
initialValues: initialValues ?? {
|
initialValues: {
|
||||||
name: "",
|
name: initialValues?.name ?? "",
|
||||||
description: "",
|
description: initialValues?.description ?? "",
|
||||||
iconUrl: "",
|
iconUrl: initialValues?.iconUrl ?? "",
|
||||||
href: "",
|
href: initialValues?.href ?? "",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,21 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
const manageAppSchema = z.object({
|
const manageAppSchema = z.object({
|
||||||
name: z.string().min(1).max(64),
|
name: z.string().trim().min(1).max(64),
|
||||||
description: z.string().max(512).nullable(),
|
description: z
|
||||||
iconUrl: z.string().min(1),
|
.string()
|
||||||
|
.trim()
|
||||||
|
.max(512)
|
||||||
|
.transform((value) => (value.length === 0 ? null : value))
|
||||||
|
.nullable(),
|
||||||
|
iconUrl: z.string().trim().min(1),
|
||||||
href: z
|
href: z
|
||||||
.string()
|
.string()
|
||||||
|
.trim()
|
||||||
.url()
|
.url()
|
||||||
.regex(/^https?:\/\//) // Only allow http and https for security reasons (javascript: is not allowed)
|
.regex(/^https?:\/\//) // Only allow http and https for security reasons (javascript: is not allowed)
|
||||||
|
.or(z.literal(""))
|
||||||
|
.transform((value) => (value.length === 0 ? null : value))
|
||||||
.nullable(),
|
.nullable(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user