1

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 ?

Guilherme Cavenaghi
  • 225
  • 1
  • 2
  • 22

1 Answers1

1

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

Guilherme Cavenaghi
  • 225
  • 1
  • 2
  • 22