Help me understand the createUpdateSchema

I am trying to build a form that will both be used for creating but also updating.

Here is what I have so far

const form = useForm({
  defaultValues: {} as z.infer<typeof insertPriceProtocol> | z.infer<typeof updatePriceProtocol>,
  validators: {
    onChange: props.priceProtocolId ? updatePriceProtocol : insertPriceProtocol,
  },
  onSubmit: async ({ value }) => {
    console.warn(value)
  },
})


My issue is however that updatePriceProtocol from createUpdateSchema (drizzle-zod) sets type as partial (undefined), meaning I can't nullify fields in the form. That don't make sense to me. What is best practice here?
Was this page helpful?