Id in zod schema for frontend and backend?
Hi guys I am saving a "client" in my backend for that I have following basic schema, which is used in my frontend and backend
I am not sure should I set the
id
to nullish or should it no be nullish?7 Replies
Because if I fetch the client I should have a id, but if I create a client I don't have an id, only after saving
Using the type in my frontend like this is that makes a difference
you can merge schemas
but i would prefer three schemas
like this
that makes sense to different schemas for different actions if needed
thanks
last time i did a upsertSchema, and later a merged with the id schema
so i had both create and update schema with same fields