24 lines
611 B
TypeScript
24 lines
611 B
TypeScript
import { z } from "zod/v4";
|
|
import { LIMITS } from "@/lib/limits";
|
|
|
|
export const upsertReviewSchema = z.object({
|
|
tripId: z.string().min(1, "Trip tidak valid"),
|
|
rating: z.coerce
|
|
.number()
|
|
.int("Rating harus bilangan bulat")
|
|
.min(1, "Rating minimal 1")
|
|
.max(5, "Rating maksimal 5"),
|
|
comment: z
|
|
.string()
|
|
.max(
|
|
LIMITS.MAX_REVIEW_COMMENT,
|
|
`Komentar maksimal ${LIMITS.MAX_REVIEW_COMMENT} karakter`
|
|
)
|
|
.transform((s) => {
|
|
const t = s.trim();
|
|
return t === "" ? undefined : t;
|
|
}),
|
|
});
|
|
|
|
export type UpsertReviewInput = z.infer<typeof upsertReviewSchema>;
|