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:
@@ -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),
|
||||
),
|
||||
)
|
||||
|
||||
+1
-1
@@ -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) => {
|
||||
|
||||
+1
-1
@@ -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',
|
||||
},
|
||||
);
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user