What is the replacement for z.ZodIssueCode.custom
02:38 04 Feb 2026

I am using React-Hook-Form 7.71.0, Zod 4.3.5, next 16.1.6

In react-hook-form useForm I am using zodresolver.

const {
    control,
    trigger,
    formState: { errors },
    handleSubmit,
    reset,
  } = useForm({
    resolver: zodResolver(fiscalPeriodRuleSchema),
    defaultValues: emptyFiscYrVar,
  });

I am using superrefine within the Zod schema to perform cross-field validation. If the calendar-based is checked, the other fields are not required. In the line code: z.ZodIssueCode.custom ZodIssueCode is marked as deprecated. What is the recommended approach to add an issue without this?

.superRefine((values, context) => {
    if (!values.calendarBased && values.name.length < 1) {
      context.addIssue({
        code: z.ZodIssueCode.custom,
        message: ' please add name',
        path: ['name'],
      });
    } else if (!values.calendarBased && !values.monthNum) {
      context.addIssue({
        code: z.ZodIssueCode.custom,
        message: 'Please add Month number',
        path: ['monthNum'],
      });
    }
next.js react-hook-form zod