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

$error state true when $pending true #1046

Closed
philBrown opened this issue Apr 21, 2022 · 1 comment
Closed

$error state true when $pending true #1046

philBrown opened this issue Apr 21, 2022 · 1 comment

Comments

@philBrown
Copy link

Describe the bug

The documentation for $error states...

Equivalent to this.$dirty && !this.$pending && this.$invalid.

However in testing it's clear that $error can be true while $pending is also true.

While async validators are executing, the $error state reports incorrectly.

Reproduction URL

I've set up a CodeSandbox example with watchers on $error, $errors and $pending here ~ https://codesandbox.io/s/nostalgic-feistel-dd80ii?file=/src/App.vue

You can see from the logs that the logic is not correct

1650509056935 "$pending:" true
1650509056937 "$error:" true
1650509056937 "$errors.length:" 0
1650509057937 "$error:" false
1650509057937 "$pending:" false

To Reproduce

Configure an async validator and use something like this to throw some errors

<p v-if="v$.field.$error">{{ v$.field.$errors[0].$message }}</p>

Expected behavior

$error should be false if $pending is true based on the documentation.

Additional context

Originally from StackOverflow here ~ https://stackoverflow.com/q/71940268/283366

@dobromir-hristov
Copy link
Contributor

Hey there, sorry for the late reply.

This was changed in #914

Please check the issue and PR and let me know what you think. We cant fix it for all cases I am afraid :/

dargmuesli added a commit to dargmuesli/vuelidate that referenced this issue May 15, 2023
As vuelidate#1046 suggests, `$error` is true when the form is `$dirty` and either `$pending` or `$invalid`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants