Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

161
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda