import * as z from "zod";
import { DevelopmentLanguageTypeEnum } from "./types";

export const searchFormSchema = z.object({
    appCode: z.string().optional(),
    appName: z.string().optional(),
    language: z.nativeEnum(DevelopmentLanguageTypeEnum).optional(),
    enabled: z.boolean().optional(),
});

export const applicationFormSchema = z.object({
    appCode: z.string().min(1, "请输入应用编码").max(50, "应用编码不能超过50个字符"),
    appName: z.string().min(1, "请输入应用名称").max(50, "应用名称不能超过50个字符"),
    appDesc: z.string().max(200, "应用描述不能超过200个字符").optional(),
    repoUrl: z.string().url("请输入有效的URL地址").min(1, "请输入仓库地址"),
    language: z.nativeEnum(DevelopmentLanguageTypeEnum, {
        required_error: "请选择开发语言",
    }),
    enabled: z.boolean().default(true),
    sort: z.number().min(0).default(0),
});

export type SearchFormValues = z.infer<typeof searchFormSchema>;
export type ApplicationFormValues = z.infer<typeof applicationFormSchema>;