Yup: oneOf is incorrectly giving false when using refs

Created on 11 Jan 2018  路  2Comments  路  Source: jquense/yup

Bug, Feature, or Question?

oneOf is incorrectly giving a false when using refs

Current Behavior

      password: yup.string().required('Password is required'),
      confirmPassword: yup.string().oneOf([yup.ref('password'), null], "Passwords don't match").required('Confirm Password is required'),

When the passwords match it is giving an error incorrectly

Desired Behavior

When the passwords match it shouldn't have any validation error

Most helpful comment

should be working in the latest version

All 2 comments

should be working in the latest version

import * as yup from 'yup'

yup
  .object({
    confirmPassword: yup
      .string()
      .oneOf([yup.ref('password'), null], "Passwords don't match")
      .required('confirm password is required'),
    password: yup.string().required(),
  })
  .isValid({
    confirmPassword: 'foobar',
    password: 'foobar',
  })
  .then(valid => console.log(valid))

Above code leads to exception , with yup version 0.24.0

Uncaught TypeError: Cannot read property 'set' of undefined
    at addToList (mixed.js:88)
Was this page helpful?
0 / 5 - 0 ratings