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

552
Views
Reactjs - Yup : How to check if 2 inputs are equal?

Im having a error when I try to use oneof frin yup

error message(enums.forEach is not a function).

My fields code :

    {...}
{({ isSubmitting }) => (
            <Form>
              <TextInput
                name="password"
                type="password"
                label="Senha"
                placeholder="***********"
                icon={<FiMail />}
              />
              <TextInput
                name="confirmpassword"
                type="password"
                label="Confirme a senha"
                placeholder="*******"
                icon={<FiLock />}
              />             
            {...}

My validation code :

{...}
 validationSchema={ 
            Yup.object({
              password: Yup.string()
                .min(8, "senha é muito curta")
                .max(30, "senha é muito longa")               
                .required("O campo senha não pode ser vazio"),
              confirmpassword: Yup.string()
                .min(8, "senha é muito curta")
                .max(30, "senha é muito longa")
                .oneOf('password','senhas devem combinar')
                .required("O campo senha não pode ser vazio"),
            })
          }
{...}

I want to validate if a field is equal the other ,someone knows how to fix it ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In yup I cant handle the equality error with this code :

FIELD: Yup.string().oneOf([Yup.ref('password'), null],'MESSAGE THAT YOU WANT TO APPEAR').min(8, 'Error')

thanks to @SoufianeBoutahlil and this link password validation with yup and formik

about 4 years ago · Juan Pablo Isaza Report
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!