gitscope
← marzneshin / v0.7.0 / dashboard/src/modules/hosts/domain/host.ts
https://dev.kronoz.win/r/marzneshin.git
dashboard/src/modules/hosts/domain/host.ts · TypeScript
Blame Raw
 1import { z } from "zod";
 2import { ProtocolType } from "@marzneshin/modules/inbounds";
 3
 4export const HostSchema = z.object({
 5    remark: z.string().min(1, "Remark is required"),
 6    address: z.string().min(1, "Address is required"),
 7    is_disabled: z.boolean().default(false),
 8    weight: z.coerce
 9        .number().int()
10        .nullable()
11        .optional(),
12    port: z
13        .preprocess(
14            (val) => (val === "" || val === undefined || val === null ? null : Number(val)),
15            z.union([
16                z
17                    .number()
18                    .int()
19                    .gte(1, "Port must be more than 1")
20                    .lte(65535, "Port cannot be more than 65535"),
21                z.null(),
22            ])
23        ),
24});
25
26
27export type HostSchemaType = z.infer<typeof HostSchema>;
28export type HostType = HostSchemaType & { id?: number, inboundId?: number, protocol: ProtocolType };