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
Generator creates zod types for your prisma models with advanced validation - chrishoermann/zod-prisma-types
Starred by 867 users
Forked by 76 users
Languages   TypeScript 99.7% | JavaScript 0.3%
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
A dream stack suggestions
The dream stack would be one where you dont need 10 different configs More on reddit.com
🌐 r/sveltejs
42
23
October 29, 2024
How to best design my schema in postgres when using zod and typescript?
If you want to stay close to SQL and avoid ORMs (good for you), I'd recommend PgTyped. It'll generate types from raw SQL queries automatically. As for Zod schema, you could then use ts-to-zod to take your TS types (generated by PgTyped) to generate Zod schemas Then you have a full generated type safety and validation driven only by raw SQL and no ORMs More on reddit.com
🌐 r/node
44
26
October 10, 2024
🌐
npm
npmjs.com › package › zod-prisma-types
zod-prisma-types - npm
January 24, 2026 - zod-prisma-types is a generator for prisma that generates zod schemas from your prisma models. This includes schemas of models, enums, inputTypes, argTypes, filters and so on. It also provides options to write advanced zod validators directly ...
      » npm install zod-prisma-types
    
Published   Jan 24, 2026
Version   3.3.11
🌐
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
🌐
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.
🌐
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 › 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!!

Find elsewhere
🌐
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 - When an API request arrives, it's untyped data from the outside world. Zod bridges this gap: it validates the incoming data at runtime so that only valid, correctly-typed data reaches your Prisma queries.
🌐
GitHub
github.com › ciscoheat › prisma-to-zod
GitHub - ciscoheat/prisma-to-zod: Generate Zod validation schemas from a Prisma schema. · GitHub
July 19, 2024 - This project was experimental, zod-prisma-types does everything you need and more. Simple generator of Zod validation schemas from Prisma schemas.
Author   ciscoheat
🌐
Omar-dulaimi
omar-dulaimi.github.io › prisma-zod-generator
Prisma Zod Generator
Starter to Enterprise: automate validation, docs, redaction, and drift guard while staying in your Prisma flow. 🚀Get Started✨ Start 14‑day Trial⚙️ConfigurationGitHub ... Built with modern development in mind, featuring everything you need for production-ready applications. ... Auto-generate Zod schemas from your Prisma schema with multiple output modes.
🌐
GitHub
github.com › wladpaiva › zod-prisma-utils
GitHub - wladpaiva/zod-prisma-utils: A Zod schema type validator for Prisma models
A Zod schema type validator for Prisma models. Contribute to wladpaiva/zod-prisma-utils development by creating an account on GitHub.
Author   wladpaiva
🌐
YouTube
youtube.com › watch
Effortless Data Validation in Node.js with Zod & Prisma ORM | Mastering Form Validation - YouTube
"Elevate your Node.js development skills by mastering data validation using Zod and Prisma ORM! In this tutorial, we'll guide you through the process of impl...
Published   November 16, 2023
🌐
npm
npmjs.com › package › prisma-zod-generator
prisma-zod-generator - npm
Unify Prisma validation, policy guardrails, and developer workflows in a single generator. 🚀 Get PZG Pro – Purchase on GitHub | 📚 Documentation | 🛡️ Drift Guard · Prisma → Zod generator for end-to-end workflows. 🚀 generate validation · 🔐 gate policies ·
      » npm install prisma-zod-generator
    
Published   Feb 14, 2026
Version   2.1.4
🌐
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
🌐
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.
🌐
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
# Install npm install -D prisma-zod-generator # Add to schema.prisma generator zod { provider = "prisma-zod-generator" } # Generate npx prisma generate · Point your config file at the published JSON Schema to get autocomplete, hover docs, and validation errors in any JSON-aware editor:
Starred by 824 users
Forked by 77 users
Languages   TypeScript 95.2% | JavaScript 3.1% | CSS 1.6% | Shell 0.1%
🌐
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.