Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async validation fails if promise resolved with some data #3895

Closed
afitiskin opened this issue Mar 6, 2018 · 3 comments
Closed

Async validation fails if promise resolved with some data #3895

afitiskin opened this issue Mar 6, 2018 · 3 comments

Comments

@afitiskin
Copy link
Contributor

What is the current behavior?

We have a form with async validation (same as in Async Blur Validation Example)

We have a following validation function:

const asyncValidate = (values/*, dispatch */) => {
  return sleep(1000)
    .then(() => {
      return new Promise((resolve, reject) => {
        if ([ 'john', 'paul', 'george', 'ringo' ].includes(values.username)) {
          reject({ username: 'That username is taken' })
        } else {
          resolve('You shall not pass!')
        }
      })
    })
}

In case of success validation, promise is resolved with some data (in our case just string You shall not pass!).

Async validation works just fine, but submitting of the form is impossible.
Error in console after submit: (index):1 Uncaught (in promise) You shall not pass!

What is the expected behavior?

Async validation returns promise, if promise is resolved (no matter with or without data provided) – async validation should pass and form submission should work as usual.

Sandbox Link

Live example: https://redux-form-broken-validation.herokuapp.com/
Live example source code: https://github.com/afitiskin/redux-form/tree/broken-async-validation-example/examples/brokenAsyncValidation

What's your environment?

Latest versions of packages and browsers

It is a duplicate of #2056 with formal bug report.

@afitiskin
Copy link
Contributor Author

Added live example to codesandbox: https://codesandbox.io/s/vo2mj9y8y

@erikras
Copy link
Member

erikras commented Jun 12, 2018

Fix released in v7.4.0.

@lock
Copy link

lock bot commented Jun 12, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants