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, '应用编码不能为空'),
    appName: z.string().min(1, '应用名称不能为空'),
    appDesc: z.string().max(200, "应用描述不能超过200个字符").optional(),
    applicationCategoryId: z.number({
        required_error: '请选择应用分类',
        invalid_type_error: '应用分类必须是数字',
    }),
    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>;