1

I have the following code:

passwordConfirmation: yup.string().oneOf([yup.ref("password")], "Passwords do not match")

However, this does not work if the passwordConfirmation field is empty (using Formik). I don't understand why yup treats an empty value as correct. It's very unintuitive. I could add required(...) though, but I would like to only have one error message -- namely "Passwords do not match".

HelloWorld
  • 3,381
  • 5
  • 32
  • 58
  • [Duplicate ?](https://stackoverflow.com/questions/61862252/yup-schema-validation-password-and-confirmpassword-doesnt-work) – tcconstantin Feb 21 '22 at 14:08
  • @tcconstantin how duplicate? specifically stating that this does not work if the passwordConfirmation field is empty, which is not what you linked to – HelloWorld Feb 22 '22 at 08:23

0 Answers0