diff --git a/lib/schemas.ts b/lib/schemas.ts new file mode 100644 index 0000000..ebeb77f --- /dev/null +++ b/lib/schemas.ts @@ -0,0 +1,80 @@ +import { z } from 'zod'; + +export const preSubmitMovieSchema = z.object({ + title: z.string().min(1).max(255), + watched: z.boolean(), + rating: z.number().min(0).max(5), + notes: z.string().min(0).max(255), +}).strict(); +export type PreSubmitMovie = z.infer; + +export const MovieSchema = z.object({ + id: z.number(), + title: z.string(), + watched: z.boolean().default(false), + rating: z.number().min(0).max(5).default(0), + notes: z.string().default(''), +}).strict(); +export type Movie = z.infer; + +export const MoviesSchema = z.array(MovieSchema); +export type Movies = z.infer; + +export const PreSubmitShowSchema = z.object({ + title: z.string().min(1).max(255), + //watchState unwatched = 0 | watching = 1 | watched = 2 + watchState: z.number().min(0).max(2), + rating: z.number().min(0).max(5), + notes: z.string().min(0).max(255), + currentSeason: z.number().min(0).max(1000), + currentEpisode: z.number().min(0).max(1000), +}).strict(); +export type PreSubmitShow = z.infer; + +export const ShowSchema = z.object({ + id: z.number(), + title: z.string().min(1).max(255), + //watchState unwatched = 0 | watching = 1 | watched = 2 + watchState: z.number().min(0).max(2), + rating: z.number().min(0).max(5), + notes: z.string().min(0).max(255), + currentSeason: z.number().min(0).max(1000), + currentEpisode: z.number().min(0).max(1000), +}).strict(); +export type Show = z.infer; + +export const ShowsSchema = z.array(ShowSchema); +export type Shows = z.infer; + +export const OtherSchema = z.object({ + id: z.number(), + title: z.string(), + //conpleteState TBD = 0 | In Progress = 1 | Completed = 2 + completeState: z.number().min(0).max(2), + rating: z.number().min(0).max(5).default(0), + notes: z.string().optional(), + currentSeason: z.number().min(0).max(1000).default(0), + currentEpisode: z.number().min(0).max(1000).default(0), + category: z.number(), +}).strict(); +export type Other = z.infer; + +export const OthersSchema = z.array(OtherSchema); +export type Others = z.infer; + +export const CategorySchema = z.object({ + id: z.number(), + title: z.string(), + showEpisodes: z.boolean().default(false), +}).strict(); +export type Category = z.infer; + +export const CategoriesSchema = z.array(CategorySchema); +export type Categories = z.infer; + + +export const TestTableShema = z.object({ + id: z.number(), + test: z.string(), +}).strict(); +export type TestTable = z.infer;