© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago•
1 reply
fstodulski

[postgres][zod] createInsertSchema

Hey! Trying to make my Sveltekit form schema.
Here is my example:
export const userAccessesFormSchema = createInsertSchema(usersTable, {
  id: z.string().min(1),
  hasDatabase: z.boolean(),
  hasMsaa: z.boolean(),
  hasMsap: z.boolean()
}).pick({
  id: true,
  hasDatabase: true,
  hasMsaa: true,
  hasMsap: true
});
export const userAccessesFormSchema = createInsertSchema(usersTable, {
  id: z.string().min(1),
  hasDatabase: z.boolean(),
  hasMsaa: z.boolean(),
  hasMsap: z.boolean()
}).pick({
  id: true,
  hasDatabase: true,
  hasMsaa: true,
  hasMsap: true
});

User has many other fields, but in this case I wan't to use only these to update this user with data.

Why am I getting rest of the fields in the result?
I don't want to check them..Am I doing something wrong?
Based on this:
https://orm.drizzle.team/docs/zod


Basically I need to take few fields from my User schema, make them fully required so I won't have to check after
safeParse()
safeParse()
if the value is
undefined
undefined
...
Screenshot_2024-04-21_at_13.48.57.png
Drizzle ORM - drizzle-zod
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
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 createInsertSchema types
Drizzle TeamDTDrizzle Team / help
3y ago
Unexpected behaviour of drizzle-zod createInsertSchema
Drizzle TeamDTDrizzle Team / help
12mo ago
drizzle-zod createInsertSchema gives optional types
Drizzle TeamDTDrizzle Team / help
2y ago
createInsertSchema
Drizzle TeamDTDrizzle Team / help
2y ago