Async validators display errors when still resolving promise
See original GitHub issueDescribe the bug Async validators seem to display errors when the promise is still resolving.
Reproduction URL https://codesandbox.io/s/vuelidate-requiredif-issue-forked-xe5ef?file=/src/App.vue
To Reproduce Steps to reproduce the behavior:
- Type some text in the box
- See that the
asyncTest
error is shown when resolving the promise - See that when the
asyncTest
promise is resolved the error is hidden
Expected behavior I would expect while resolving the promise not error to be shown until the Promise returns a false. Sometimes something needs to be validated in the backend and can some time to respond resulting in misleading customers.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Consider a form invalid while async validator promises are ...
I know two ways to invalidate a form while async validators are pending, but they're both verbose and/or hacky. // Workaround 1: Mark...
Read more >Async Validators | JET Developer Cookbook - Oracle
The async validator's validate method returns a Promise that resolves if validation passes and value is updated or rejects with an Error if...
Read more >Async Blur Validation Example - Redux Form
Asynchronous validation will not be called if synchronous validation is failing for the field just blurred. The errors are displayed in the exact...
Read more >Mongoose v6.8.2: Validation
There are two equivalent ways to set the validator error message: ... If your validator function returns a promise (like an async function),...
Read more >The hard error handling case made easy with async/await
We can try to fix this by starting a Promise context and moving the catch down. function(request, response, next) { return Promise.resolve() .then(()...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We always had $invalid, it just used to be
true
, while the validator was resolving.I changed that in the PR to keep it
false
, so no error messages are shown, but the field itself is considered errored, so we don’t accidentally submit a form, while it’s validating.@dobromir-hristov atm. I actually check if it’s pending to solve this problem.
But having errors in the error list when it’s not sure if there is even going to be an error is kind of weird developer experience if you ask me.