zeekrey
zeekrey
DTDrizzle Team
Created by zeekrey on 11/28/2023 in #help
Custom error messages with drizzle-zod?
This is how I do it at the moment, but it feels bad since I overwrite the schema to make it form compatible 😂. I'm looking for a way to: a) Add custom Zod error messages without the need to rewrite the type. b) Remove null from the type. I found schema.transform, but this runs after validation, so it can't be used to inherit a type for validation.
6 replies
DTDrizzle Team
Created by zeekrey on 11/28/2023 in #help
Custom error messages with drizzle-zod?
I would like to add another thing: createInsertSchema creates a Zod schema that uses ZodNullable (since all non-required fields could be null). However, this requires you to modify the schema again because it's not possible to use this schema with any input (since null cannot be assigned to an input). What is the best way to handle this? To solve these issues, I currently overwrite almost any field since I need a) a custom error message or b) need to convert null to undefined. 😥
6 replies