Answers for "yup making confirm password required only if password exists"

1

yup validate password confirmation

import * as Yup from 'yup';

validationSchema: Yup.object({
  password: Yup.string().required('Password is required'),
  passwordConfirmation: Yup.string()
     .oneOf([Yup.ref('password'), null], 'Passwords must match')
});
Posted by: Guest on June-30-2021
0

Yup password confirm password

Yup.object({
  password: Yup.string().required('Password is required'),
  passwordConfirmation: Yup.string()
    .test('passwords-match', 'Passwords must match', function(value){
      return this.parent.password === value
    })
})
Posted by: Guest on April-18-2021

Code answers related to "yup making confirm password required only if password exists"

Browse Popular Code Answers by Language