add types and schemas

This commit is contained in:
ItsMalma
2025-11-08 13:51:18 +07:00
parent b347ab0250
commit e6386648be
28 changed files with 1082 additions and 101 deletions

View File

@@ -0,0 +1,122 @@
import { dateSchema, timeSchema } from "@/common/schemas";
import z from "zod";
export const packageRequestSchema = z.object({
name: z
.string("Must be string.")
.nonempty("Must not empty.")
.max(100, "Max 100 characters."),
type: z.enum(["reguler", "plus"], "Must be either 'reguler' or 'plus'."),
class: z.enum(
["silver", "gold", "platinum"],
"Must be either 'silver', 'gold', or 'platinum'.",
),
thumbnail: z.base64("Must be base64 string.").nonempty("Must not empty."),
use_fast_train: z.boolean("Must be boolean."),
});
export const packageDetailRequestSchema = z.object({
departure_date: dateSchema,
tour_flight_slugs: z
.array(
z
.string("Must be string.")
.nonempty("Must not empty.")
.max(420, "Max 420 characters."),
"Must be array.",
)
.nonempty("Must not empty."),
outbound_flight_slugs: z
.array(
z
.string("Must be string.")
.nonempty("Must not empty.")
.max(420, "Max 420 characters."),
"Must be array.",
)
.nonempty("Must not empty."),
inbound_flight_slugs: z
.array(
z
.string("Must be string.")
.nonempty("Must not empty.")
.max(420, "Max 420 characters."),
"Must be array.",
)
.nonempty("Must not empty."),
tour_hotels: z.array(
z.object(
{
hotel_slug: z
.string("Must be string.")
.nonempty("Must not empty.")
.max(200, "Max 200 characters."),
check_in: timeSchema,
check_out: timeSchema,
},
"Must be object.",
),
"Must be array.",
),
makkah_hotel: z.object(
{
hotel_slug: z
.string("Must be string.")
.nonempty("Must not empty.")
.max(200, "Max 200 characters."),
check_in: timeSchema,
check_out: timeSchema,
},
"Must be object.",
),
madinah_hotel: z.object(
{
hotel_slug: z
.string("Must be string.")
.nonempty("Must not empty.")
.max(200, "Max 200 characters."),
check_in: timeSchema,
check_out: timeSchema,
},
"Must be object.",
),
transportation_slug: z
.string("Must be string.")
.nonempty("Must not empty.")
.max(200, "Max 200 characters."),
quad_price: z
.number("Must be number.")
.int("Must be integer.")
.positive("Must be positive."),
triple_price: z
.number("Must be number.")
.int("Must be integer.")
.positive("Must be positive."),
double_price: z
.number("Must be number.")
.int("Must be integer.")
.positive("Must be positive."),
infant_price: z
.number("Must be number.")
.int("Must be integer.")
.positive("Must be positive.")
.nullable(),
});
export const packageQuerySchema = z.object({
detail_slug: z
.string("Must be string.")
.nonempty("Must not empty.")
.max(200, "Max 200 characters."),
slug: z
.string("Must be string.")
.nonempty("Must not empty.")
.max(200, "Max 200 characters."),
});
export const packageDetailQuerySchema = z.object({
slug: z
.string("Must be string.")
.nonempty("Must not empty.")
.max(200, "Max 200 characters."),
});