© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
2 replies
Cetus 🔛🔝

drizzle-zod refine enum

Here's my users table and the schema generated with
drizzle-zod
drizzle-zod
that I want to modify. As you can see, the role column is an enum, but I want to modify the error message as I did with email and password. I've tried several solutions but nothing works, could you help me?
export const roleEnum = pgEnum('role', ['USER', 'ADMIN'])

export const users = pgTable('users', {
  id: serial('id').primaryKey(),
  email: varchar('email', {
    length: 256,
  })
    .unique()
    .notNull(),
  password: varchar('password', {
    length: 256,
  }).notNull(),
  role: roleEnum('role').notNull(),
})

export const insertUserSchema = createInsertSchema(users, {
  email: schema => schema.email.email("Format de l'adresse email incorrect"),
  password: schema => schema.password.min(8, "Le mot de passe doit contenir au moins 8 caractères"),
})
export const roleEnum = pgEnum('role', ['USER', 'ADMIN'])

export const users = pgTable('users', {
  id: serial('id').primaryKey(),
  email: varchar('email', {
    length: 256,
  })
    .unique()
    .notNull(),
  password: varchar('password', {
    length: 256,
  }).notNull(),
  role: roleEnum('role').notNull(),
})

export const insertUserSchema = createInsertSchema(users, {
  email: schema => schema.email.email("Format de l'adresse email incorrect"),
  password: schema => schema.password.min(8, "Le mot de passe doit contenir au moins 8 caractères"),
})
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

drizzle-zod object scoped refine
Drizzle TeamDTDrizzle Team / help
3y ago
Drizzle-Zod
Drizzle TeamDTDrizzle Team / help
9mo ago
Why is drizzle-zod converting a string to enum?
Drizzle TeamDTDrizzle Team / help
3y ago
Drizzle update enum
Drizzle TeamDTDrizzle Team / help
3y ago