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 validations aren't propagated to all generated schemas #137

Closed
ghoshnirmalya opened this issue May 3, 2023 · 2 comments
Closed
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@ghoshnirmalya
Copy link

Description

For the following model:

model Project {
  id          Int      @id @default(autoincrement())
  title       String /// @zod.string.min(4).max(10)
  creatorId   String

  author User @relation(fields: [creatorId], references: [id])

  @@index([creatorId])
}

ProjectCreateInputSchema show the correct validations:

export const ProjectCreateInputSchema: z.ZodType<Prisma.ProjectCreateInput> = z.object({
  title: z.string().min(4).max(10),
  author: z.lazy(() => UserCreateNestedOneWithoutProjectsInputSchema)
}).strict();

However, ProjectCreateWithoutAuthorInputSchema doesn't show the correct validations:

export const ProjectCreateWithoutAuthorInputSchema: z.ZodType<Prisma.ProjectCreateWithoutAuthorInput> = z.object({
  title: z.string(),
}).strict();

Expected behaviour

The title attribute should be the following:

- title: z.string(),
+ title: z.string().min(4).max(10)
@chrishoermann
Copy link
Owner

@ghoshnirmalya thanks for the report. This is currently not implemented. I need to refine the logic that determines if the inputSchema should be validated.

@chrishoermann chrishoermann self-assigned this May 3, 2023
@chrishoermann chrishoermann added bug Something isn't working enhancement New feature or request labels May 3, 2023
@chrishoermann
Copy link
Owner

@ghoshnirmalya should work now in the latest version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
Development

No branches or pull requests

2 participants