diff --git a/apps/demo/package.json b/apps/demo/package.json index 04f0b5789..0431b76f4 100644 --- a/apps/demo/package.json +++ b/apps/demo/package.json @@ -34,7 +34,7 @@ "react-redux": "8.1.3", "react-router-dom": "6.30.4", "react-toastify": "11.1.0", - "zod": "3.25.76" + "zod": "4.4.3" }, "devDependencies": { "@babel/core": "7.29.7", diff --git a/apps/demo/src/Views/Form/components/FormInput/FormInput.tsx b/apps/demo/src/Views/Form/components/FormInput/FormInput.tsx index 04aa738b7..79d5aab5e 100644 --- a/apps/demo/src/Views/Form/components/FormInput/FormInput.tsx +++ b/apps/demo/src/Views/Form/components/FormInput/FormInput.tsx @@ -32,7 +32,7 @@ export const FormInputDemo = () => { name: zod.string().min(1, t("formInput.message.required")), number: zod .number({ - required_error: t("formInput.message.required"), + error: t("formInput.message.required"), }) .nullable() .refine((data) => data !== null, { diff --git a/packages/form/package.json b/packages/form/package.json index 811bde594..7aba28089 100644 --- a/packages/form/package.json +++ b/packages/form/package.json @@ -34,12 +34,12 @@ }, "dependencies": { "@hookform/error-message": "2.0.1", - "@hookform/resolvers": "3.10.0", + "@hookform/resolvers": "5.5.7", "react-debounce-input": "3.3.0", "react-dropzone": "14.4.1", "react-hook-form": "7.82.0", "validator": "13.15.35", - "zod": "3.25.76" + "zod": "4.4.3" }, "devDependencies": { "@prefabs.tech/eslint-config": "0.8.7", diff --git a/packages/form/src/components/Form.tsx b/packages/form/src/components/Form.tsx index d9841ee5e..bcbf7e8a7 100644 --- a/packages/form/src/components/Form.tsx +++ b/packages/form/src/components/Form.tsx @@ -1,7 +1,8 @@ +import type { ZodType } from "zod"; + import { zodResolver } from "@hookform/resolvers/zod"; import React, { Children, createElement } from "react"; import { useForm, UseFormProps } from "react-hook-form"; -import { ZodEffects, ZodObject } from "zod"; interface IForm extends UseFormProps { // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -10,8 +11,9 @@ interface IForm extends UseFormProps { html5Validation?: boolean; // eslint-disable-next-line @typescript-eslint/no-explicit-any onSubmit: (data: any) => void; + // eslint-disable-next-line @typescript-eslint/no-explicit-any - validationSchema?: ZodEffects | ZodObject; + validationSchema?: ZodType; } export const Form: React.FC = ({ diff --git a/packages/form/src/components/FormProvider.tsx b/packages/form/src/components/FormProvider.tsx index f18aec1d4..8f3c9df6c 100644 --- a/packages/form/src/components/FormProvider.tsx +++ b/packages/form/src/components/FormProvider.tsx @@ -1,7 +1,8 @@ +import type { ZodType } from "zod"; + import { zodResolver } from "@hookform/resolvers/zod"; import React, { useEffect } from "react"; import { FormProvider, useForm, UseFormProps } from "react-hook-form"; -import { ZodEffects, ZodObject } from "zod"; import { FormSubmitOptions } from ".."; @@ -11,8 +12,9 @@ interface IForm extends UseFormProps { html5Validation?: boolean; // eslint-disable-next-line @typescript-eslint/no-explicit-any onSubmit: (data: any, options?: FormSubmitOptions) => any; + // eslint-disable-next-line @typescript-eslint/no-explicit-any - validationSchema?: ZodEffects | ZodObject; + validationSchema?: ZodType; validationTriggerKey?: string; } diff --git a/packages/form/src/types/index.ts b/packages/form/src/types/index.ts index eee3e6e4e..9f24e65c2 100644 --- a/packages/form/src/types/index.ts +++ b/packages/form/src/types/index.ts @@ -1,3 +1,5 @@ +import type { ZodObject } from "zod"; + import { FieldValues, UseFormClearErrors, @@ -8,13 +10,12 @@ import { UseFormResetField, UseFormSetError, } from "react-hook-form"; -import { ZodObject } from "zod"; // eslint-disable-next-line @typescript-eslint/no-explicit-any export type AdditionalDefaultValues = Record; // eslint-disable-next-line @typescript-eslint/no-explicit-any -export type AdditionalFormSchema = ZodObject; +export type AdditionalFormSchema = ZodObject; export type FormSubmitOptions = { diff --git a/packages/user/package.json b/packages/user/package.json index c6acede64..e031c3f91 100644 --- a/packages/user/package.json +++ b/packages/user/package.json @@ -34,7 +34,7 @@ }, "dependencies": { "supertokens-web-js": "0.6.0", - "zod": "3.25.76" + "zod": "4.4.3" }, "devDependencies": { "@prefabs.tech/eslint-config": "0.8.7", diff --git a/packages/user/src/components/Invitation/InvitationForm.tsx b/packages/user/src/components/Invitation/InvitationForm.tsx index 4214fc259..64ce4ffde 100644 --- a/packages/user/src/components/Invitation/InvitationForm.tsx +++ b/packages/user/src/components/Invitation/InvitationForm.tsx @@ -192,7 +192,7 @@ export const InvitationForm = ({ if (apps?.length || roles?.length) { const RoleFormSchema = zod.object({ - role: zod.string({ required_error: t("validation.messages.role") }), + role: zod.string({ error: t("validation.messages.role") }), }); InvitationFormSchema = InvitationFormSchema.merge(RoleFormSchema); @@ -201,7 +201,7 @@ export const InvitationForm = ({ if (apps?.length) { const AppIdFormSchema = zod.object({ app: zod.number({ - required_error: t("validation.messages.app"), + error: t("validation.messages.app"), }), }); @@ -211,7 +211,7 @@ export const InvitationForm = ({ if (expiryDateField?.display) { const ExpiresAtFormSchema = zod.object({ expiresAt: zod.date({ - required_error: t("validation.messages.expiresAt"), + error: t("validation.messages.expiresAt"), }), }); diff --git a/packages/user/src/components/Profile/ProfileForm.tsx b/packages/user/src/components/Profile/ProfileForm.tsx index 1d0f66f2b..6347460f9 100644 --- a/packages/user/src/components/Profile/ProfileForm.tsx +++ b/packages/user/src/components/Profile/ProfileForm.tsx @@ -26,7 +26,8 @@ export const ProfileForm = ({ const config = useConfig(); const [submitting, setSubmitting] = useState(false); - let profileValidationSchema: z.AnyZodObject = z.object({ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let profileValidationSchema: z.ZodObject = z.object({ givenName: z .string() .min(1, t("profile.form.validations.firstName.required")), diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 816852dd4..d1a994885 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -81,8 +81,8 @@ importers: specifier: 11.1.0 version: 11.1.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1) zod: - specifier: 3.25.76 - version: 3.25.76 + specifier: 4.4.3 + version: 4.4.3 devDependencies: '@babel/core': specifier: 7.29.7 @@ -223,8 +223,8 @@ importers: specifier: 2.0.1 version: 2.0.1(react-dom@18.3.1(react@18.3.1))(react-hook-form@7.82.0(react@18.3.1))(react@18.3.1) '@hookform/resolvers': - specifier: 3.10.0 - version: 3.10.0(react-hook-form@7.82.0(react@18.3.1)) + specifier: 5.5.7 + version: 5.5.7(@standard-schema/spec@1.1.0)(ajv@8.17.1)(react-hook-form@7.82.0(react@18.3.1))(zod@4.4.3) react-debounce-input: specifier: 3.3.0 version: 3.3.0(react@18.3.1) @@ -238,8 +238,8 @@ importers: specifier: 13.15.35 version: 13.15.35 zod: - specifier: 3.25.76 - version: 3.25.76 + specifier: 4.4.3 + version: 4.4.3 devDependencies: '@prefabs.tech/eslint-config': specifier: 0.8.7 @@ -586,8 +586,8 @@ importers: specifier: 0.6.0 version: 0.6.0 zod: - specifier: 3.25.76 - version: 3.25.76 + specifier: 4.4.3 + version: 4.4.3 devDependencies: '@prefabs.tech/eslint-config': specifier: 0.8.7 @@ -1292,10 +1292,83 @@ packages: react-dom: '>=16.8.0' react-hook-form: ^7.0.0 - '@hookform/resolvers@3.10.0': - resolution: {integrity: sha512-79Dv+3mDF7i+2ajj7SkypSKHhl1cbln1OGavqrsF7p6mbUv11xpqpacPsGDCTRvCSjEEIez2ef1NveSVL3b0Ag==} + '@hookform/resolvers@5.5.7': + resolution: {integrity: sha512-CyPCYV8/KlXfEXLWj8HHHhVsR/IZ6Ckm3b/a4fWtO/lRnRK1huqncb8LlAWrmpPRsse5glF5aVuDRMHEr3UGag==} peerDependencies: - react-hook-form: ^7.0.0 + '@sinclair/typebox': '>=0.25.24' + '@standard-schema/spec': ^1.0.0 + '@typeschema/main': '>=0.13.7' + '@vinejs/vine': ^2.0.0 || ^3.0.0 + ajv: ^8.12.0 + ajv-errors: ^3.0.0 + ajv-formats: ^2.1.1 + arktype: ^2.0.0 + ata-validator: ^0.7.0 + class-transformer: '>=0.4.0' + class-validator: '>=0.12.0' + computed-types: ^1.0.0 + effect: ^3.10.3 + fluentvalidation-ts: ^3.0.0 + fp-ts: ^2.7.0 + io-ts: ^2.0.0 + joi: ^17.0.0 + nope-validator: '>=0.12.0' + react-hook-form: ^7.55.0 + superstruct: '>=0.12.0' + typanion: ^3.3.2 + valibot: '>=0.31.0 || ^1.0.0-beta.4 || ^1.0.0-rc' + vest: '>=3.0.0' + yup: ^1.0.0 + zod: ^3.25.0 || ^4.0.0 + peerDependenciesMeta: + '@sinclair/typebox': + optional: true + '@standard-schema/spec': + optional: true + '@typeschema/main': + optional: true + '@vinejs/vine': + optional: true + ajv: + optional: true + ajv-errors: + optional: true + ajv-formats: + optional: true + arktype: + optional: true + ata-validator: + optional: true + class-transformer: + optional: true + class-validator: + optional: true + computed-types: + optional: true + effect: + optional: true + fluentvalidation-ts: + optional: true + fp-ts: + optional: true + io-ts: + optional: true + joi: + optional: true + nope-validator: + optional: true + superstruct: + optional: true + typanion: + optional: true + valibot: + optional: true + vest: + optional: true + yup: + optional: true + zod: + optional: true '@humanfs/core@0.19.1': resolution: {integrity: sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==} @@ -1763,6 +1836,9 @@ packages: '@standard-schema/spec@1.1.0': resolution: {integrity: sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==} + '@standard-schema/utils@0.3.0': + resolution: {integrity: sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g==} + '@tanstack/react-table@8.21.3': resolution: {integrity: sha512-5nNMTSETP4ykGegmVkhjcS8tTLW6Vl4axfEGQN3v0zdHYbK4UfoqfPChclTrJ4EoK9QynqAu9oUf8VEmrpZ5Ww==} engines: {node: '>=12'} @@ -4979,8 +5055,8 @@ packages: peerDependencies: zod: ^3.25.0 || ^4.0.0 - zod@3.25.76: - resolution: {integrity: sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==} + zod@4.4.3: + resolution: {integrity: sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==} snapshots: @@ -5546,7 +5622,7 @@ snapshots: eslint: 10.7.0(jiti@2.4.2) ts-pattern: 5.9.0 typescript: 6.0.3 - zod: 3.25.76 + zod: 4.4.3 transitivePeerDependencies: - supports-color @@ -5598,9 +5674,14 @@ snapshots: react-dom: 18.3.1(react@18.3.1) react-hook-form: 7.82.0(react@18.3.1) - '@hookform/resolvers@3.10.0(react-hook-form@7.82.0(react@18.3.1))': + '@hookform/resolvers@5.5.7(@standard-schema/spec@1.1.0)(ajv@8.17.1)(react-hook-form@7.82.0(react@18.3.1))(zod@4.4.3)': dependencies: + '@standard-schema/utils': 0.3.0 react-hook-form: 7.82.0(react@18.3.1) + optionalDependencies: + '@standard-schema/spec': 1.1.0 + ajv: 8.17.1 + zod: 4.4.3 '@humanfs/core@0.19.1': {} @@ -6030,6 +6111,8 @@ snapshots: '@standard-schema/spec@1.1.0': {} + '@standard-schema/utils@0.3.0': {} + '@tanstack/react-table@8.21.3(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': dependencies: '@tanstack/table-core': 8.21.3 @@ -7210,8 +7293,8 @@ snapshots: '@babel/parser': 7.29.2 eslint: 10.7.0(jiti@2.4.2) hermes-parser: 0.25.1 - zod: 3.25.76 - zod-validation-error: 4.0.2(zod@3.25.76) + zod: 4.4.3 + zod-validation-error: 4.0.2(zod@4.4.3) transitivePeerDependencies: - supports-color @@ -9465,8 +9548,8 @@ snapshots: yoctocolors@2.1.2: {} - zod-validation-error@4.0.2(zod@3.25.76): + zod-validation-error@4.0.2(zod@4.4.3): dependencies: - zod: 3.25.76 + zod: 4.4.3 - zod@3.25.76: {} + zod@4.4.3: {}