mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-02-14 19:59:17 +00:00
Export InstallMethodSchema and integrate into JSONGenerator for better validation of install method data input
This commit is contained in:
parent
1b7f14b224
commit
8afa8e9e09
@ -1,6 +1,6 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const InstallMethodSchema = z.object({
|
||||
export const InstallMethodSchema = z.object({
|
||||
type: z.enum(["default", "alpine"], {
|
||||
errorMap: () => ({ message: "Type must be either 'default' or 'alpine'" })
|
||||
}),
|
||||
|
@ -24,7 +24,7 @@ import { z } from "zod";
|
||||
import { format } from "date-fns";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { AlertColors } from "@/config/siteConfig";
|
||||
import { ScriptSchema } from "./_schemas/schemas";
|
||||
import { InstallMethodSchema, ScriptSchema } from "./_schemas/schemas";
|
||||
|
||||
type Script = z.infer<typeof ScriptSchema>;
|
||||
|
||||
@ -91,17 +91,7 @@ export default function JSONGenerator() {
|
||||
|
||||
const addInstallMethod = () => {
|
||||
setScript((prev) => {
|
||||
const method: {
|
||||
type: "default" | "alpine";
|
||||
script: string;
|
||||
resources: {
|
||||
cpu: number | null;
|
||||
ram: number | null;
|
||||
hdd: number | null;
|
||||
os: string | null;
|
||||
version: number | null;
|
||||
};
|
||||
} = {
|
||||
const method = InstallMethodSchema.parse({
|
||||
type: "default",
|
||||
script: `/${prev.type}/${prev.slug}.sh`,
|
||||
resources: {
|
||||
@ -111,7 +101,7 @@ export default function JSONGenerator() {
|
||||
os: null,
|
||||
version: null,
|
||||
},
|
||||
};
|
||||
});
|
||||
return {
|
||||
...prev,
|
||||
install_methods: [...prev.install_methods, method],
|
||||
|
Loading…
Reference in New Issue
Block a user