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

160
Views
How validation react-hook-form multistep with yup.test only one time?

My react-hook-form with 3 step

return (
<section className="flex max-w-x">
  <form onSubmit={handleSubmit(onSubmit)} className="mx-auto my-0 w-2/5">
    <FirstStep
      show={formStep === 1}
      register={register}
      errors={errors}
      onNextClick={async () => {
        setFormStep((await trigger(['email', 'password', 'passwordConfirm'])) ? 2 : 1);
      }}
    />
    <SecondStep
      show={formStep === 2}
      register={register}
      errors={errors}
      onNextClick={async () => {
        setFormStep((await trigger(['firstname', 'lastname', 'middlename', 'typeClient', 'phone'])) ? 3 : 2);
      }}
      onBackClick={() => setFormStep(1)}
    />
    <ThirdStep
      show={formStep === 3}
      register={register}
      errors={errors}
      onBackClick={() => setFormStep(2)}
      isSubmitting={isSubmitting}
    />
  </form>
 </section>
);

and have yup validators for phone and email input

 email: email.test(
    'isUnique',
    translate('signupFormScheme.email_is_busy'),
    async (value) => !value || await AuthService.checkEmail(value) === true,
  ),
 phone: phone.test(
    'isUnique',
    translate('signupFormScheme.phone_is_busy'),
    async (value) => !value || await AuthService.checkPhone(value) === true,
  ).required(translate('signupFormScheme.phone_must_be_filled')),

When I push button on the first step, yup start work validation for email input, after then i push button on the second step and again start work validators for email input and phone. And then again I push buton Signup on the last step and again start work validation for email and phone input.

Why yup its do? because I use triger(react-hook-form) Thaks for answer

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!