final-form / final-form/react-final-form
Async Validation Marks Invalid Field as Valid
- Dominant language
- JavaScript
- Stars
- 7.4k
- Forks
- 497
- PR merge metrics
- No merged PRs in 30d
Description
### Are you submitting a **bug report** or a **feature request**?
Not sure which category it falls under.
### What is the current behavior?
Async validation clears out existing error on field (from sync validation) and makes field valid when it is actually invalid.
### What is the expected behavior?
Async validation should not mark a field as valid if it is invalid.
### Sandbox Link
https://codesandbox.io/s/kl9n295n5
This is the same link from the repo under Hybrid Synchronous/Asynchronous Record-Level Validation. You just need to type in one of the names that will fail async validation. Then let the async request return and then quickly delete the name. The sync validation will mark the field as Required but then it gets wiped out by the resolving async validation which passes since the name is valid.
### What's your environment?
final-form 4.11.0
react-final-form 4.0.2
react 16.4.1
Chrome 71
Ubuntu 18
Node 10.12.0
### Other information
As a side note (this should probably be another issue), I tried to use a debounced promise for async validation to reduce the amount of api requests. It doesn't play well with react-final-form. Whenever the async validation is triggered, the validating property is set to true and doesn't get changed back so submitting the form doesnt work. Again this is only for debounced promises for async validation. So I decided to just remove async validation since I still have to validate uniqueness on the backend anyway.
Contributor guide
Assessment
This issue has not been assessed yet.