Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Zod Schema in an Int field stills adds .int() at the end #147

Open
lugrinder opened this issue Aug 19, 2022 · 0 comments
Open

Custom Zod Schema in an Int field stills adds .int() at the end #147

lugrinder opened this issue Aug 19, 2022 · 0 comments

Comments

@lugrinder
Copy link

For example, a schema like this:

model Test {
  id    Int @id @default(autoincrement())
  /// @zod.custom(z.nativeEnum(imports.State))
  state Int @default(0)
}

Where State is defined in imports like:

export enum State {
  ONE,
  TWO,
  THREE
}

Generates:

export const TestModel = z.object({
  id: z.number().int(),
  state: z.nativeEnum(imports.State).int()
})

Which is invalid because nativeEnum is number and don't have .int().
I can replace with a custom refine, but this is not the question...

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

No branches or pull requests

1 participant