Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
4 changes: 2 additions & 2 deletions packages/form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 4 additions & 2 deletions packages/form/src/components/Form.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<any> | ZodObject<any>;
validationSchema?: ZodType<any, any, any>;
}

export const Form: React.FC<IForm> = ({
Expand Down
6 changes: 4 additions & 2 deletions packages/form/src/components/FormProvider.tsx
Original file line number Diff line number Diff line change
@@ -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 "..";

Expand All @@ -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<any> | ZodObject<any>;
validationSchema?: ZodType<any, any, any>;
validationTriggerKey?: string;
}

Expand Down
5 changes: 3 additions & 2 deletions packages/form/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { ZodObject } from "zod";

import {
FieldValues,
UseFormClearErrors,
Expand All @@ -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<string, any>;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type AdditionalFormSchema = ZodObject<any>;
export type AdditionalFormSchema = ZodObject<any, any>;

export type FormSubmitOptions<TFieldValues extends FieldValues = FieldValues> =
{
Expand Down
2 changes: 1 addition & 1 deletion packages/user/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions packages/user/src/components/Invitation/InvitationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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"),
}),
});

Expand All @@ -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"),
}),
});

Expand Down
3 changes: 2 additions & 1 deletion packages/user/src/components/Profile/ProfileForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<any, any> = z.object({
givenName: z
.string()
.min(1, t("profile.form.validations.firstName.required")),
Expand Down
123 changes: 103 additions & 20 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading