Defines Zod schemas for creating, retrieving, and updating store data, including validation and slug generation.
// Source: https://github.com/sadmann7/skateshop | License: MIT | Copyright 2024 Sadman Sakib
// Provided via justclaw.it.com; keep this notice with the code.
import * as z from "zod"
import { slugify } from "@/lib/utils"
export const createStoreSchema = z
.object({
name: z.string().min(3).max(50),
description: z.string().optional(),
slug: z.string().optional(),
})
.refine((data) => {
if (!data.slug) {
data.slug = slugify(data.name)
}
return true
})
export const getStoreSchema = z.object({
id: z.number(),
userId: z.string(),
})
export const getStoresSchema = z.object({
page: z.coerce.number().default(1),
per_page: z.coerce.number().default(10),
sort: z.string().optional().default("productCount.desc"),
statuses: z.string().optional(),
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key