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

230
Views
How to validate current password against new password using Yup

I am using yup and yup-password to validate password creation on my app and ran into a problem when validating New Password against Current Password. I needed to find a way to throw an error if the new password matches the existing one.

I had a bit of a hard time finding this answered anywhere, so I thought I'd create this issue and answer it myself. Hope it helps someone!

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

0

Came across this function on yup documentation, and here's the implementation:

const newPasswordField = () =>
  passwordField().notOneOf(
    [Yup.ref('currentPassword'), null],
    'passwords must be different'
  );

When the newPassword matches currentPassword, an error is thrown with the message 'passwords must be different'.

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!