zod-prisma-types icon indicating copy to clipboard operation
zod-prisma-types copied to clipboard

[BUG] Zog schema methods not working

Open moltco opened this issue 1 year ago • 2 comments

Describe the bug I am new to zog-prisma-types and have encountered what I believe is a bug.

The following Prisma schema wirh rich comments will fail

model Test{
/// @zod.cuid()
id String @id @default(cuid())
/// @zod.describe("Your name")
name String
}

Erros received from zod-prisma-types: (1) [@zod generator error]: 'describe' is not a valid validator type. [Error Location]: Model: 'Test', Field: 'name'. (2) [@zod generator error]: 'cuid' is not a valid validator type. [Error Location]: Model: 'Test, Field: 'id'.

I noticed .cuid2() does not work either. However .email() and many others work.

I consider this to be a bug as it shouold be a basic use case. I would assume that the generator parses everything it understands but the stuff it does not understand (or care about) -- it should just add to the list. The .describe() is a good example of this. Otherwise I need to create 5 different transformations from model to zod to get a complete set of generated files.

Is there a workaround for .describe()? I guess .cuid() is likely to be auto-generated by the generator.

Screenshots If applicable, add screenshots to help explain your problem.

Package versions (please complete the following information):

  • zod: 3.23.8
  • prisma: 5.20

Additional context Add any other context about the problem here.

moltco avatar Sep 30 '24 16:09 moltco

I get the same [@zod generator error]: 'describe' is not a valid validator type. [Error Location]: Model: 'Task', Field: 'createdAt'.

Just tested it

semy avatar Nov 13 '24 15:11 semy

Shouldn't they be @zod.string().cuid() and @zod.string(). describe()?

CHC383 avatar Nov 14 '24 02:11 CHC383