Drizzle-Zod

"zod": "^3.25.36" "drizzle-zod": "^0.8.2", Previously I was able to re-use schema.
export const createTrainingSchema = trainingToBeInsertedSchema
.extend({
duration: z.coerce.number().min(1),
categoryIds: z.array(
z.object({
label: z.string(),
value: z.string(),
}),
),
})
.required();
export const createTrainingSchema = trainingToBeInsertedSchema
.extend({
duration: z.coerce.number().min(1),
categoryIds: z.array(
z.object({
label: z.string(),
value: z.string(),
}),
),
})
.required();
// Used for PATCH
export const trainingToBeInsertedSchema = createInsertSchema(TB_Trainings, {
name: (schema) => schema.optional(),
description: (schema) => schema.optional(),
posterId: (schema) => schema.min(1).optional(),
})
.extend({
categoryIds: z.array(z.string()).min(1).optional(),
})
.pick({
name: true,
description: true,
duration: true,
categoryIds: true,
posterId: true,
isFree: true,
isVisible: true,
isNew: true,
});
// Used for PATCH
export const trainingToBeInsertedSchema = createInsertSchema(TB_Trainings, {
name: (schema) => schema.optional(),
description: (schema) => schema.optional(),
posterId: (schema) => schema.min(1).optional(),
})
.extend({
categoryIds: z.array(z.string()).min(1).optional(),
})
.pick({
name: true,
description: true,
duration: true,
categoryIds: true,
posterId: true,
isFree: true,
isVisible: true,
isNew: true,
});
After update to latest version I'm getting errors.
No description
7 Replies
fstodulski
fstodulskiOP5mo ago
Is there any information about migration? Looks like Usage is different now..
Queen Elizabeth II
Latest versions of drizzle-zod use Zod v4 only
fstodulski
fstodulskiOP5mo ago
@Shroom saw github:
"peerDependencies": {
"drizzle-orm": ">=0.36.0",
"zod": "^3.25.1"
},
"devDependencies": {
"@rollup/plugin-typescript": "^11.1.0",
"@types/node": "^18.15.10",
"cpy": "^10.1.0",
"drizzle-orm": "link:../drizzle-orm/dist",
"json-rules-engine": "^7.3.1",
"rimraf": "^5.0.0",
"rollup": "^3.29.5",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^3.1.3",
"zod": "3.25.1",
"zx": "^7.2.2"
}
"peerDependencies": {
"drizzle-orm": ">=0.36.0",
"zod": "^3.25.1"
},
"devDependencies": {
"@rollup/plugin-typescript": "^11.1.0",
"@types/node": "^18.15.10",
"cpy": "^10.1.0",
"drizzle-orm": "link:../drizzle-orm/dist",
"json-rules-engine": "^7.3.1",
"rimraf": "^5.0.0",
"rollup": "^3.29.5",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^3.1.3",
"zod": "3.25.1",
"zx": "^7.2.2"
}
Queen Elizabeth II
not exactly sure what you're tyring to show me here well as in i know what it is. but why
fstodulski
fstodulskiOP5mo ago
from peer deps of drizzle-zod - it doesn;t show exactly they use zod-4
Queen Elizabeth II
it shows exactly that zod 4 is currently shipped together with 3 so like there's no specific zod@4 that you can install yet

Did you find this page helpful?