diff --git a/src/test/functional/optional/expected/post.ts b/src/test/functional/optional/expected/post.ts index f04c6586..b98eefe8 100644 --- a/src/test/functional/optional/expected/post.ts +++ b/src/test/functional/optional/expected/post.ts @@ -16,5 +16,5 @@ export interface CompletePost extends z.infer { * NOTE: Lazy required in case of potential circular dependencies within schema */ export const RelatedPostModel: z.ZodSchema = z.lazy(() => PostModel.extend({ - author: RelatedUserModel.nullish(), + author: RelatedUserModel.nullable(), })) diff --git a/src/test/functional/optional/expected/user.ts b/src/test/functional/optional/expected/user.ts index abfad2a8..ef140166 100644 --- a/src/test/functional/optional/expected/user.ts +++ b/src/test/functional/optional/expected/user.ts @@ -22,5 +22,5 @@ export interface CompleteUser extends z.infer { * NOTE: Lazy required in case of potential circular dependencies within schema */ export const RelatedUserModel: z.ZodSchema = z.lazy(() => UserModel.extend({ - posts: RelatedPostModel.nullish(), + posts: RelatedPostModel.nullable(), })) diff --git a/src/test/functional/relation-1to1/expected/user.ts b/src/test/functional/relation-1to1/expected/user.ts index 81d2bec5..c0c1c6df 100644 --- a/src/test/functional/relation-1to1/expected/user.ts +++ b/src/test/functional/relation-1to1/expected/user.ts @@ -15,5 +15,5 @@ export interface CompleteUser extends z.infer { * NOTE: Lazy required in case of potential circular dependencies within schema */ export const RelatedUserModel: z.ZodSchema = z.lazy(() => UserModel.extend({ - keychain: RelatedKeychainModel.nullish(), + keychain: RelatedKeychainModel.nullable(), })) diff --git a/src/test/types.test.ts b/src/test/types.test.ts index 46dc908d..ef001699 100644 --- a/src/test/types.test.ts +++ b/src/test/types.test.ts @@ -20,7 +20,7 @@ describe('types Package', () => { const constructor = getZodConstructor(field) - expect(constructor).toBe('z.string().array().max(64).min(1).nullish()') + expect(constructor).toBe('z.string().array().max(64).min(1).nullable()') }) test('regression - unknown type', () => { diff --git a/src/types.ts b/src/types.ts index 0a108974..42f7936f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -51,7 +51,7 @@ export const getZodConstructor = ( zodType = computeCustomSchema(field.documentation) ?? zodType extraModifiers.push(...computeModifiers(field.documentation)) } - if (!field.isRequired && field.type !== 'Json') extraModifiers.push('nullish()') + if (!field.isRequired && field.type !== 'Json') extraModifiers.push('nullable()') // if (field.hasDefaultValue) extraModifiers.push('optional()') return `${zodType}${extraModifiers.join('.')}`