diff --git a/package.json b/package.json index cbe79f4..fa7fba9 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "react-dom": "^18.2.0", "react-hook-form": "^7.51.3", "tailwind-merge": "^2.2.2", - "tailwindcss-animate": "^1.0.7" + "tailwindcss-animate": "^1.0.7", + "zod": "^3.22.4" }, "devDependencies": { "@types/node": "^20.12.7", diff --git a/src/interfaces/schema.ts b/src/interfaces/schema.ts index de14f32..071337e 100644 --- a/src/interfaces/schema.ts +++ b/src/interfaces/schema.ts @@ -1,3 +1,22 @@ -import { GroupField } from "./group"; +import { z } from "zod"; -export type SchemaType = GroupField; +export const FieldTypeDef = z.object({ + type: z.literal("field"), + dataType: z.enum(["text", "number", "email"]), + fieldName: z.string(), + accessorKey: z.string(), +}); + +type GroupFieldType = { + type: "group"; + fields: (z.infer | GroupFieldType)[]; +}; + +export const GroupTypeDef: z.ZodType = z.object({ + type: z.literal("group"), + fields: z.array(z.union([FieldTypeDef, z.lazy(() => GroupTypeDef)])), +}); + +export const SchemaDef = GroupTypeDef; + +export type SchemaType = z.infer; diff --git a/src/schemas/forms/personal_info.d.json.ts b/src/schemas/forms/personal_info.d.json.ts deleted file mode 100644 index 13ee3ee..0000000 --- a/src/schemas/forms/personal_info.d.json.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { SchemaType } from "@/interfaces/schema"; - -declare const personal_info: SchemaType; - -export default personal_info; diff --git a/tsconfig.json b/tsconfig.json index 4e63707..fb00b7d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,6 @@ /* Bundler mode */ "moduleResolution": "bundler", - "allowArbitraryExtensions": true, "allowImportingTsExtensions": true, "resolveJsonModule": true, "isolatedModules": true, diff --git a/yarn.lock b/yarn.lock index 92abac0..b224ac1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2226,3 +2226,8 @@ yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== + +zod@^3.22.4: + version "3.22.4" + resolved "https://registry.yarnpkg.com/zod/-/zod-3.22.4.tgz#f31c3a9386f61b1f228af56faa9255e845cf3fff" + integrity sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==