TanStackT
TanStack11mo ago
11 replies
broad-emerald

Type errors when adding a validator zod schema and initializing the default value to null.

I have a schema where the field month is validated to be non null.

const schema = z.object({ month: z.coerce.date()})


on the form end

  const form = useAppForm({
    defaultValues: {
        month: null
    },
    validators: {
      onSubmit: schema, //type error at the onSubmit because month is 'null'
    },
})


I don't want to initialize with a date, since its a MonthPickerInput component. What are the options?
Month, multiple months and months range picker input
MonthPickerInput | Mantine
Was this page helpful?