Skip to content

Conversation

tinglei8
Copy link

@tinglei8 tinglei8 commented Jan 3, 2025

This fix solves an issue of properly flattening zod schemas referenced in chained function calls.

An example:

import { z } from 'zod';

const TypeEnum = z
  .enum(['Normal', 'Unknown'])
  .describe('Type of the item');

const FindManyInput = z.object({
  options: z
    .object({
      userId: z.string().describe('ID of the current user'),
      type1: TypeEnum.optional().describe('Type 1 of the item')
    })
    .merge({
      z.object({
        type2: TypeEnum.optional().describe('Type 2 of the item')
      })
    })
    .describe('Options to find many items'),
});

Before the fix, references to TypeEnum are not flattened in FindManyInput because it's referenced as parameters of the object() and merge() calls instead of the last describe() call.

After the fix, The TypeEnum schema is properly flattened in all places that reference it.

Copy link

vercel bot commented Jan 3, 2025

@tinglei8 is attempting to deploy a commit to the Kevin's Projects Team on Vercel.

A member of the Team first needs to authorize it.

@tinglei8
Copy link
Author

tinglei8 commented Jan 3, 2025

Closed because #59 contains it

@tinglei8 tinglei8 closed this Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant