From 40bea786fa0e5abc35ae139f2723e3666c993354 Mon Sep 17 00:00:00 2001 From: Jason Lin Date: Tue, 25 Jun 2024 17:37:50 -0400 Subject: [PATCH] Use preprocess instead of transform. Fix loss of types from preprocessNulls returning any instead of schema type. --- .../src/domain-models/contractAndRates/formDataTypes.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/services/app-api/src/domain-models/contractAndRates/formDataTypes.ts b/services/app-api/src/domain-models/contractAndRates/formDataTypes.ts index ca2587c5fb..c92d7db5bf 100644 --- a/services/app-api/src/domain-models/contractAndRates/formDataTypes.ts +++ b/services/app-api/src/domain-models/contractAndRates/formDataTypes.ts @@ -1,4 +1,3 @@ -import type { ZodSchema } from 'zod' import { z } from 'zod' import { actuaryCommunicationTypeSchema, @@ -14,6 +13,7 @@ import { } from '../../../../app-web/src/common-code/proto/healthPlanFormDataProto/zodSchemas' import { statusSchema } from './statusType' import type { ZodEffects } from 'zod/lib/types' +import type { RawCreateParams, ZodTypeAny } from 'zod/lib/types' const documentSchema = z.object({ name: z.string(), @@ -36,8 +36,11 @@ const packagesWithSharedRateCerts = z.object({ packageStatus: statusSchema.optional(), }) -function preprocessNulls(schema: T): ZodEffects { - return z.preprocess((val) => val ?? undefined, schema) +function preprocessNulls( + schema: T, + params?: RawCreateParams +): ZodEffects { + return z.preprocess((val) => val ?? undefined, schema, params) } const contractFormDataSchema = z.object({