Open t18n opened 2 weeks ago
I would like to be able to achieve this
const myZodSchema = z.object({ property: z.integer().min(5).max(10) property2: z.integer().min(5).max(10) }) const myZodSchemaOnlyCheckType = z.stripKeywords(myZodSchema, ['min', 'max']) // Should return z.object({ property: z.integer() property2: z.integer() })
Is there any way to do that?
I am building an app which uses Drizzle, Zod and Open AI.
On my app, I defined a Drizzle schema and generate a zod schema from it.
import { createInsertSchema } from 'drizzle-zod'; export const profiles = pgTable( 'profiles', { headline: varchar('headline', { length: 255 }).notNull(), }, ); export const insertProfileSchema = createInsertSchema(profiles);
then send the schema over to Open AI to get Structured output.
The generated Zod schema would include the length check. However, OpenAI doesn't support some keyword at the moment, including maxLength. So that's why I am trying to work around this.
length
I've tried with createSelectSchema from drizzle-zod without luck.
createSelectSchema
drizzle-zod
Any other more elegant solutions are welcomed. :)
I would like to be able to achieve this
Is there any way to do that?
Some context
I am building an app which uses Drizzle, Zod and Open AI.
On my app, I defined a Drizzle schema and generate a zod schema from it.
then send the schema over to Open AI to get Structured output.
The generated Zod schema would include the
length
check. However, OpenAI doesn't support some keyword at the moment, including maxLength. So that's why I am trying to work around this.I've tried with
createSelectSchema
fromdrizzle-zod
without luck.Any other more elegant solutions are welcomed. :)