Migrate from Zod v3 to v4 (#14639)

Closes [#1526](https://github.com/twentyhq/core-team-issues/issues/1526)

---------

Co-authored-by: Félix Malfait <felix@twenty.com>
Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
This commit is contained in:
Abdul Rahman
2025-09-24 21:59:05 +05:30
committed by GitHub
parent 8d78032357
commit 3cada58908
98 changed files with 809 additions and 1075 deletions
@@ -49,8 +49,12 @@ const StyledComboInputContainer = styled.div`
const validationSchema = z
.object({
firstName: z.string().min(1, { message: 'First name can not be empty' }),
lastName: z.string().min(1, { message: 'Last name can not be empty' }),
firstName: z.string().min(1, {
error: 'First name can not be empty',
}),
lastName: z.string().min(1, {
error: 'Last name can not be empty',
}),
})
.required();
@@ -54,9 +54,7 @@ const StyledActionSkipLinkContainer = styled.div`
`;
const validationSchema = z.object({
emails: z.array(
z.object({ email: z.union([z.literal(''), z.string().email()]) }),
),
emails: z.array(z.object({ email: z.union([z.literal(''), z.email()]) })),
});
type FormInput = z.infer<typeof validationSchema>;
@@ -27,22 +27,20 @@ export const SettingsSecurityApprovedAccessDomain = () => {
const form = useForm<{ domain: string; email: string }>({
mode: 'onSubmit',
resolver: zodResolver(
z
.object({
domain: z
.string()
.regex(
/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])\.[a-zA-Z]{2,}$/,
{
message: t`Domains have to be smaller than 256 characters, cannot contain spaces and cannot contain any special characters.`,
},
)
.max(256),
email: z.string().min(1, {
message: t`Email cannot be empty`,
}),
})
.strict(),
z.strictObject({
domain: z
.string()
.regex(
/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])\.[a-zA-Z]{2,}$/,
{
message: t`Domains have to be smaller than 256 characters, cannot contain spaces and cannot contain any special characters.`,
},
)
.max(256),
email: z.string().min(1, {
message: t`Email cannot be empty`,
}),
}),
),
defaultValues: {
email: '',