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
@@ -1,6 +1,5 @@
import { z } from 'zod';
import { type FieldMetadataItemOption } from '@/object-metadata/types/FieldMetadataItem';
import { themeColorSchema } from 'twenty-ui/theme';
import { computeOptionValueFromLabel } from '~/pages/settings/data-model/utils/computeOptionValueFromLabel';
@@ -22,9 +21,9 @@ const selectOptionSchema = z
}
},
{
message: 'Label is not transliterable',
error: 'Label is not transliterable',
},
) satisfies z.ZodType<FieldMetadataItemOption>;
);
export const selectOptionsSchema = z
.array(selectOptionSchema)
@@ -35,7 +34,7 @@ export const selectOptionsSchema = z
return new Set(optionIds).size === options.length;
},
{
message: 'Options must have unique ids',
error: 'Options must have unique ids',
},
)
.refine(
@@ -44,13 +43,13 @@ export const selectOptionsSchema = z
return new Set(optionValues).size === options.length;
},
{
message: 'Options must have unique values',
error: 'Options must have unique values',
},
)
.refine(
(options) =>
[...options].sort().every((option, index) => option.position === index),
{
message: 'Options positions must be sequential',
error: 'Options positions must be sequential',
},
);