Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
React-hook-form validation - IsValid prop keeps returning false

I have a fairly complex form using React-Hook-Form. I am unable to get the validation to work correctly.

The zod library validation schema is as such:

// For the form to be valid, 
// Atleast 2 goal forms, with min. 1 task
export const schemaZod = z.object({
  goals: z
    .object({
      title: z.string().min(3, { message: "required" }).max(40),
      intro: z.string().max(250).optional(),
      deadline: (z.string() || z.date()).optional(),
      task: z
        .object({
          content: z.string().min(3, { message: "required" }).max(50),
          dayFrequency: z.number().min(0).max(5).optional(),
          weekFrequency: z.number().min(0).max(7).optional(),
        })
        .array()
        .min(1),
    })
    .array()
    .min(2),
});

  const ctx = useForm({
    mode: "onChange",
    resolver: zodResolver(schemaZod),
  });

Here is a working CodeSandBox example, sincere apologies for so much code. Its a complex form & I am unable to get the validation formState.isValid to be true, even when the conditions are met.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!