You are forgotting to use await inside signUpLogic.

And the validations are not working. I still can enter the wrong email format into the email field.

You are not using zod to parse the data.

You can do the following:

export const createUser = async ({ 
  username,
  email,
  password,
}: UserModel) => {
  const user: UserModel = await prisma.user.create({
    data: {
      username,
      email,
      password,
    },
  });
  return user;
};
export const signUpLogic = async (req: Request, res: Response) => {
  const { username, email, password } = req.body;
  try {
    const hashedPassword = await bcrypt.hash(password, 10);
    
    const result = userSchema.safeParse({ username, email, password: String(hashedPassword)});

    if(result.success) {
      await createUser(result.data);
    } else {
      // handle wrong parsing result
    }
  } catch (err) {
    if (err instanceof PrismaClientKnownRequestError) {
      if (err.code === "P2002") {
        res.json({ message: "email already taken" });
      }
    }
  }
};
Answer from Nullndr on Stack Overflow
🌐
GitHub
github.com › chrishoermann › zod-prisma-types
GitHub - chrishoermann/zod-prisma-types: Generator creates zod types for your prisma models with advanced validation · GitHub
Decimals are a special case since they are not supported by zod out of the box. Therefore the generator utilizes the Prisma.Decimal class and the DecimalJsLike type from the @prisma/client package and - if installed - the decimal.js package. A downside of this approach is that Prisma can't be simply imported as a type anymore because it is used to determine if an instance of Prisma.Decimal is passed in. When using Decimal a refine method is used to validate if the input adheres to the prisma input union string | number | Decimal | DecimalJsLike.
Starred by 867 users
Forked by 76 users
Languages   TypeScript 99.7% | JavaScript 0.3%
🌐
Prisma
prisma.io › home › custom validation › custom validation › custom validation › custom validation › custom validation
Custom validation | Prisma Documentation
In this example, validations are only run on the top level data object passed to methods such as prisma.product.create(). Validations implemented this way do not automatically run for nested writes. ... import { PrismaClient, Prisma } from "../prisma/generated/client"; import { z } from "zod"; /** * Zod schema */ export const ProductCreateInput = z.object({ slug: z .string() .max(100) .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/), name: z.string().max(100), description: z.string().max(1000), price: z .instanceof(Prisma.Decimal) .refine((price) => price.gte("0.01") && price.lt("1000000.00")), }) satisfi
Discussions

Zod validator using Prisma (MySQL) enum
Have you tried this? https://github.com/colinhacks/zod#native-enums More on reddit.com
🌐 r/typescript
5
3
August 25, 2023
Which source of truth in a TS/Zod/Prisma project?
I don't know if it's the best practic but you can create decorators on your entities class and properties in order to generate metadata. Then you can create a function that read those metadata and build prisma validators from them. And another one for Zod validation. I did something similar with an Angular / NestJS / TypeORM stack and it was working fine More on reddit.com
🌐 r/typescript
18
11
July 17, 2023
How to infere type from Prisma with Zod
Prisma generates very good types for you. In my opinion, it's the main reason to use Prisma in TS projects. It looks like you figured out the solution to your type error the right way; if you're only using the email from the User interface inside the function, just pass that single thing as an argument. That's generally a good pattern, even without Typescript. You might want to do some validation that the email is correctly formatted at some point, ideally before you let a user submit it to be added to your database. More on reddit.com
🌐 r/nextjs
2
4
March 9, 2023
Library for NestJS GraphQL and Zod
Hey u/incetarik , this library is perfect for what we want to do, which is using zod schema as the sources of truth to scaffold (with customisation) dynamodb models, gql object types and input types, compose various combinations of these with partial/omitted fields etc and export this goodness for the front-end in the monorepo as well. This is an absolute killer pattern imo. I'm having trouble with compiling under ts@4.9.5, however. Simply using any of the exports of this library throws errors on types `Mapper` and `MapKeys` being undefined. node_modules/nestjs-graphql-zod/dist/model-from-zod.d.ts:74:84 - error TS2304: Cannot find name 'Mapper'.74 export interface IModelFromZodOptionsWithMapper = Mapper> extends IModelFromZodOptions {~~~~~~node_modules/nestjs-graphql-zod/dist/model-from-zod.d.ts:74:96 - error TS2304: Cannot find name 'Mapper'.74 export interface IModelFromZodOptionsWithMapper = Mapper> extends IModelFromZodOptions {~~~~~~node_modules/nestjs-graphql-zod/dist/model-from-zod.d.ts:86:49 - error TS2304: Cannot find name 'Mapper'.86 type Options = Mapper> = IModelFromZodOptionsWithMapper & {~~~~~~node_modules/nestjs-graphql-zod/dist/model-from-zod.d.ts:86:61 - error TS2304: Cannot find name 'Mapper'.86 type Options = Mapper> = IModelFromZodOptionsWithMapper & {~~~~~~node_modules/nestjs-graphql-zod/dist/model-from-zod.d.ts:98:13 - error TS2304: Cannot find name 'MapKeys'.98 new (): MapKeys; I see they are defined in `types.d.ts`, but not imported or defined in any of the dist files. Importing anything directly from the src directory still yields the same problem. I'm reasonably new to typescript, would be awesome if you could comment, I've surely walked into similar problems before. My tsconfig: "compilerOptions": {"include": ["src/**/*.ts"],"exclude": ["node_modules/**/*"]"experimentalDecorators": true,"lib": ["ESNext", "DOM", "DOM.Iterable"],"moduleResolution": "node","noUnusedLocals": false,"noUnusedParameters": false,"removeComments": true,"sourceMap": true,"outDir": "dist","module": "commonjs","esModuleInterop": true,"declaration": true,"emitDecoratorMetadata": true,"allowSyntheticDefaultImports": true,"target": "ES2020","incremental": true,"alwaysStrict": true,"strictNullChecks": true,"resolveJsonModule": true,} More on reddit.com
🌐 r/Nestjs_framework
4
6
May 8, 2022
🌐
Reddit
reddit.com › r/typescript › zod validator using prisma (mysql) enum
r/typescript on Reddit: Zod validator using Prisma (MySQL) enum
August 25, 2023 -

Hi,

I'm trying to make a zod validator, it should parse data coming from frontend form (im using next.js app router)

here are code snippets:

schema.prisma:

model ProposalOption {
  id                Int                 @id @default(autoincrement())
  name              String              @db.TinyText
  category          OptionCategory
  active            Boolean
}

enum OptionCategory {
  reason
  size
  feature
  additional
}

now based off that schema i would like to create a zod validator, but idk how to define that...

import z from "zod";
import type { OptionCategory } from "@prisma/client";

const options: OptionCategory[] = ["additional", "feature", "reason", "size"];

export const CreateProposalOptionValidator = z.object({
  description: z
    .string()
    .min(5, { message: "Description must have at least 5 characters" })
    .max(100, { message: "Description must have less than 100 characters" }),
  // @ts-expect-error TODO: fix this
  category: z.enum(options),
});

export type ProposalOptionCreateRequest = z.infer<
  typeof CreateProposalOptionValidator
>;

unfortunately category key is atm just a string, not a OptionCategory, therefore on the backend i have a type error

    const body = await req.json();
    const { category, description } = CreateProposalOptionValidator.parse(body);

    await db.proposalOption.create({
      data: {
        // @ts-expect-error
        category,
        description,
      },
    });

Any hints?
Thanks in advance!!

🌐
npm
npmjs.com › package › zod-prisma-types
zod-prisma-types - npm
January 24, 2026 - Decimals are a special case since they are not supported by zod out of the box. Therefore the generator utilizes the Prisma.Decimal class and the DecimalJsLike type from the @prisma/client package and - if installed - the decimal.js package. A downside of this approach is that Prisma can't be simply imported as a type anymore because it is used to determine if an instance of Prisma.Decimal is passed in. When using Decimal a refine method is used to validate if the input adheres to the prisma input union string | number | Decimal | DecimalJsLike.
      » npm install zod-prisma-types
    
Published   Jan 24, 2026
Version   3.3.11
🌐
GitHub
github.com › wladpaiva › zod-prisma-utils
GitHub - wladpaiva/zod-prisma-utils: A Zod schema type validator for Prisma models
Since Prisma has a special way to handle decimal and json fields, we also provide a decimal and json function that you can use to define your schema. import { z } from "zod"; import type { Prisma } from "@prisma/client"; import * as zpu from "zod-prisma-utils"; export const TransactionSchema = z.object({ amount: zpu.decimal(), metadata: zpu.json(), } satisfies Schema<Prisma.TransactionCreateInput>);
Author   wladpaiva
🌐
GitHub
github.com › ciscoheat › prisma-to-zod
GitHub - ciscoheat/prisma-to-zod: Generate Zod validation schemas from a Prisma schema. · GitHub
July 19, 2024 - Will generate a typescript file, ready for additional validations. If no output file is specified, the schema will be written to stdout. NOTE: This should currently be regarded as a one-step process, since any additional generation will overwrite your modifications. A future version will update the schema without overwriting. import { prismaToZod } from "prisma-to-zod"; import fs from "fs"; const schema = fs.readFileSync("prisma/schema.prisma", { encoding: "utf8" }); console.log(prismaToZod(schema));
Author   ciscoheat
Find elsewhere
🌐
Lambdaworks
lambdaworks.io › blog › from-prisma-to-zod
From Prisma to Zod • LambdaWorks Blog
February 11, 2026 - Zod schema validates it at runtime. OpenAPI docs are generated from the same Zod schema. Yes – your database schema and all that you’ve specified there, now becomes your API schema, both in runtime behavior and documentation. The best code is the code you don’t have to write – or even worse, maintain in four different places. By using the most out of your Prisma schema and turning it into Zod schemas and then OpenAPI docs, you unlock a streamlined, scalable, and type-safe development workflow that’s easier to debug and easier to love.
🌐
Medium
medium.com › @narcis.fanica › building-a-rest-api-with-typescript-express-prisma-zod-and-neon-db-part-6-schema-validation-09bca19a15e9
Building a REST API with TypeScript, Express, Prisma, Zod, and Neon DB: Part 6 — Schema Validation with Zod | by Narcis Fanica | Medium
October 12, 2024 - In this article, we’ll explore schema validation in our REST API using Zod. We’ll start by understanding what Zod is and how to define and parse schemas. Then, we’ll create middleware to validate incoming requests, build and use various schemas for our endpoints and test the implementation.
🌐
Reddit
reddit.com › r/typescript › which source of truth in a ts/zod/prisma project?
r/typescript on Reddit: Which source of truth in a TS/Zod/Prisma project?
July 17, 2023 -

I have a Typescript project and want to use form validation with Zod on the front end. I’m also using Prisma ORM. The issue is I’m struggling to get one source of truth for the resource being created/updated. How do you keep those in sync? At the moment, I have 3 separate schemas. What’s the best practice to define your schema once and keep TS, DB and frontend validation in sync?

🌐
JS2TS
js2ts.com › blog › prisma-typescript-zod-validation-guide
Prisma with TypeScript and Zod: The Complete Validation Guide
May 22, 2026 - Learn how to use Prisma with Zod for runtime validation in TypeScript. Covers creating Zod schemas from Prisma models, tRPC integration, and API validation patterns.
🌐
GitHub
github.com › prisma › prisma › discussions › 22058
Advice on implementing custom validation with Prisma Client · prisma/prisma · Discussion #22058
Write Zod schemas for the models that need custom validation to validate email/url/other fields · Create a Prisma Client Extension that uses all of the Zod schemas I've written.
Author   prisma
🌐
Steve Kinney
stevekinney.com › courses › full stack typescript › generate zod schemas from prisma
Generate Zod Schemas from Prisma | Full Stack TypeScript | Steve Kinney
March 17, 2026 - Learn to generate Zod schemas from Prisma using `zod-prisma-types`. Simplify validation by integrating Zod with your Prisma setup effortlessly.
🌐
Medium
medium.com › @polite_feldgrau_woodchuck_70 › why-is-everyone-using-prisma-zod-and-trpc-in-next-js-bfac913efcc8
Why is everyone using Prisma, Zod, and tRPC in Next.js? | by Grigor Grantovich Sargsyan | Medium
December 10, 2024 - You might use Prisma to define your database schema and perform database operations, while using Zod to validate data at the boundaries of your application (e.g., validating API request payloads before saving them to the database).
🌐
Stackademic
blog.stackademic.com › next-js-and-prisma-a-simple-guide-to-typing-endpoints-with-zod-3b7121a54473
A Simple Guide to Typing Endpoints with Zod | by Brian Ridolce | Stackademic
November 28, 2023 - import { z } from 'zod'; const UserSchema = z.object({ id: z.number(), name: z.string(), email: z.string().email(), // Add other fields as per your Prisma model }); For your Next.js API routes, use these Zod schemas to validate incoming data.
🌐
Medium
medium.com › @prismaneui › form-validation-with-zod-and-prismane-967b388996f5
Form Validation with Zod and Prismane | by Prismane | Medium
December 14, 2023 - The p function executes Zod's validator and provides the error message if there's one, or null if there are no errors. This way we can adapt the Zod validator to the structure of a Prismane validator.
🌐
DeepWiki
deepwiki.com › chrishoermann › zod-prisma-types
chrishoermann/zod-prisma-types | DeepWiki
April 24, 2025 - zod-prisma-types is a Prisma generator that automatically creates $1 schemas from your Prisma models. It generates type-safe validation schemas for models, enums, input types, argument types, and more
🌐
DEV Community
dev.to › polliog › building-a-type-safe-backend-with-trpc-zod-and-prisma-pk
Building a Type-Safe Backend with tRPC, Zod, and Prisma - DEV Community
December 3, 2025 - In this article, I'll show you ... practical examples. Before diving into the implementation, let's understand why this combination is powerful: Prisma: Type-safe database access with auto-generated types from your schema · Zod: Runtime validation with TypeScript type ...
🌐
GitHub
github.com › omar-dulaimi › prisma-zod-generator
GitHub - omar-dulaimi/prisma-zod-generator: Prisma 2+ generator to emit Zod schemas from your Prisma schema · GitHub
See the JSON Schema IntelliSense guide for monorepo examples, CI validation scripts, and tips on shipping the schema with custom tooling. See the full documentation for detailed guides, upgrade notes, and feature walkthroughs. Browse recipes/ for copy-paste presets, CI snippets, and integration templates that match your stack. Share llms.txt with AI copilots for an on-ramp to the architecture, commands, and conventions. If Prisma Zod ...
Starred by 824 users
Forked by 77 users
Languages   TypeScript 95.2% | JavaScript 3.1% | CSS 1.6% | Shell 0.1%