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
@@ -23,8 +23,9 @@ const filterQueryParamsSchema = z.object({
viewId: z.string().optional(),
filter: z
.record(
z.record(
z.nativeEnum(ViewFilterOperand),
z.string(),
z.partialRecord(
z.enum(ViewFilterOperand),
z.string().or(z.array(z.string())).or(relationFilterValueSchemaObject),
),
)
@@ -53,7 +53,7 @@ export const variableDateViewFilterValuePartsSchema = z
unit: variableDateViewFilterValueUnitSchema,
})
.refine((data) => !(data.amount === undefined && data.direction !== 'THIS'), {
message: "Amount cannot be 'undefined' unless direction is 'THIS'",
error: "Amount cannot be 'undefined' unless direction is 'THIS'",
});
const variableDateViewFilterValueSchema = z.string().transform((value) => {
@@ -14,6 +14,6 @@ export const arrayOfStringsOrVariablesSchema = z
(parsed) =>
Array.isArray(parsed) && parsed.every((item) => typeof item === 'string'),
{
message: 'Expected an array of strings',
error: 'Expected an array of strings',
},
);
@@ -12,7 +12,7 @@ export const jsonRelationFilterValueSchema = z
return JSON.parse(value);
} catch (error) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
code: 'custom',
message: (error as Error).message,
});
return z.NEVER;