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:
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { type WorkflowRunState } from '@/workflow/types/Workflow';
|
||||
import { workflowRunStateSchema } from '@/workflow/validation-schemas/workflowSchema';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { workflowRunStateSchema } from 'twenty-shared/workflow';
|
||||
import { type JsonValue } from 'type-fest';
|
||||
|
||||
export const orderWorkflowRunState = (value: JsonValue) => {
|
||||
|
||||
+1
-1
@@ -290,7 +290,7 @@ export const FieldActorValueSchema = z.object({
|
||||
name: z.string(),
|
||||
context: z
|
||||
.object({
|
||||
provider: z.nativeEnum(ConnectedAccountProvider).optional(),
|
||||
provider: z.enum(ConnectedAccountProvider).optional(),
|
||||
})
|
||||
.nullable(),
|
||||
});
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import { CurrencyCode } from '../CurrencyCode';
|
||||
import { type FieldCurrencyValue } from '../FieldMetadata';
|
||||
|
||||
const currencySchema = z.object({
|
||||
currencyCode: z.nativeEnum(CurrencyCode).nullable(),
|
||||
currencyCode: z.enum(CurrencyCode).nullable(),
|
||||
amountMicros: z.number().nullable(),
|
||||
});
|
||||
|
||||
|
||||
+6
-2
@@ -5,13 +5,17 @@ import { type FieldJsonValue, type Json } from '../FieldMetadata';
|
||||
// See https://zod.dev/?id=json-type
|
||||
const literalSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]);
|
||||
const jsonSchema: z.ZodType<Json> = z.lazy(() =>
|
||||
z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)]),
|
||||
z.union([
|
||||
literalSchema,
|
||||
z.array(jsonSchema),
|
||||
z.record(z.string(), jsonSchema),
|
||||
]),
|
||||
);
|
||||
|
||||
export const jsonWithoutLiteralsSchema: z.ZodType<FieldJsonValue> = z.union([
|
||||
z.null(), // Exclude literal values other than null
|
||||
z.array(jsonSchema),
|
||||
z.record(jsonSchema),
|
||||
z.record(z.string(), jsonSchema),
|
||||
]);
|
||||
|
||||
export const isFieldRawJsonValue = (
|
||||
|
||||
+1
-1
@@ -2,4 +2,4 @@ import { z } from 'zod';
|
||||
|
||||
import { CurrencyCode } from '@/object-record/record-field/ui/types/CurrencyCode';
|
||||
|
||||
export const currencyCodeSchema = z.nativeEnum(CurrencyCode);
|
||||
export const currencyCodeSchema = z.enum(CurrencyCode);
|
||||
|
||||
+3
-1
@@ -10,6 +10,8 @@ export const currencyFieldDefaultValueSchema = z.object({
|
||||
currencyCode: simpleQuotesStringSchema.refine(
|
||||
(value): value is `'${CurrencyCode}'` =>
|
||||
currencyCodeSchema.safeParse(stripSimpleQuotesFromString(value)).success,
|
||||
{ message: 'String is not a valid currencyCode' },
|
||||
{
|
||||
error: 'String is not a valid currencyCode',
|
||||
},
|
||||
),
|
||||
});
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const emailSchema = z.string().email();
|
||||
export const emailSchema = z.email();
|
||||
|
||||
Reference in New Issue
Block a user