From ef4c533ebacc2cdc97e518f30e9a9350004fcdfb Mon Sep 17 00:00:00 2001 From: dujinkim Date: Mon, 28 Apr 2025 02:13:30 +0000 Subject: ~20250428 작업사항 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/vendor-type/validations.ts | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 lib/vendor-type/validations.ts (limited to 'lib/vendor-type/validations.ts') diff --git a/lib/vendor-type/validations.ts b/lib/vendor-type/validations.ts new file mode 100644 index 00000000..146c404e --- /dev/null +++ b/lib/vendor-type/validations.ts @@ -0,0 +1,46 @@ +import { + createSearchParamsCache, + parseAsArrayOf, + parseAsInteger, + parseAsString, + parseAsStringEnum, +} from "nuqs/server" +import * as z from "zod" + +import { getFiltersStateParser, getSortingStateParser } from "@/lib/parsers" +import { VendorTypes } from "@/db/schema" + +export const searchParamsCache = createSearchParamsCache({ + flags: parseAsArrayOf(z.enum(["advancedTable", "floatingBar"])).withDefault( + [] + ), + page: parseAsInteger.withDefault(1), + perPage: parseAsInteger.withDefault(10), + sort: getSortingStateParser().withDefault([ + { id: "createdAt", desc: true }, + ]), + nameKo: parseAsString.withDefault(""), + nameEn: parseAsString.withDefault(""), + from: parseAsString.withDefault(""), + to: parseAsString.withDefault(""), + // advanced filter + filters: getFiltersStateParser().withDefault([]), + joinOperator: parseAsStringEnum(["and", "or"]).withDefault("and"), + search: parseAsString.withDefault(""), + +}) + +export const createVendorTypeSchema = z.object({ + nameKo: z.string(), + nameEn: z.string(), + +}) + +export const updateVendorTypeSchema = z.object({ + nameKo: z.string().optional(), + nameEn: z.string().optional(), +}) + +export type GetVendorTypesSchema = Awaited> +export type CreateVendorTypeSchema = z.infer +export type UpdateVendorTypeSchema = z.infer -- cgit v1.2.3