fix: allow additional_data to be undefined or null (#9687)

This commit is contained in:
Harminder Virk
2024-10-21 13:44:21 +05:30
committed by GitHub
parent fa15db4538
commit 63fff01f2f
5 changed files with 95 additions and 17 deletions
+4 -2
View File
@@ -1,4 +1,4 @@
import { z, ZodEffects, ZodObject } from "zod"
import { z, ZodEffects, ZodNullable, ZodObject, ZodOptional } from "zod"
/**
* Wraps the original schema to a function to accept and merge
@@ -8,7 +8,9 @@ export const WithAdditionalData = <T extends ZodObject<any, any>>(
originalSchema: T,
modifyCallback?: (schema: T) => ZodObject<any, any> | ZodEffects<any, any>
) => {
return (additionalDataValidator?: ZodObject<any, any>) => {
return (
additionalDataValidator?: ZodOptional<ZodNullable<ZodObject<any, any>>>
) => {
let schema: ZodObject<any, any>
if (!additionalDataValidator) {