-
Notifications
You must be signed in to change notification settings - Fork 532
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
Asynchronous Validators are broken #358
Comments
I think I have a solution for this, using in FormGenerator.vue, I'm modifying the
Should have a PR for this by the end of the day. |
…validators * added `validateAsync` (default: false) form option * added `isAsync` parameter to FormGenerator.validate() * FormGenerator.validate() and AbstractField.validate() return Promise when `validateAsync` or `isAsync` is true * renamed `click` handler to `onClick` in FieldSubmit * added `onValidationError(model, schema, errors)` to FieldSubmit schema to handle validation errors * added async validator support for FieldSupport * changed `each` to `forEach` in various places, as "each" is an alias to "forEach" and "forEach" looks more explicit * removed call to Vue.util.hyphenate as this is no longer supported by Vue, replaced with equivalent `String.replace` expression * updated fieldSubmit.spec to add "valid form" and "invalid form" tests, valid forms will always call `onSubmit`, invalid forms will not call `onSubmit` (when validateBeforeSubmit = true) * various code clean up
fixes #358 - support "validateBeforeSubmit" with async validators
@arnKo that PR solves this issue, but to maintain backwards compatibility you’ll have to add “validayeAsyc: true” to your formOptions being passed to VFG. That will tell VFG to wait on async validators before calling the onSubmit callback, and the VFG validate method will return a Promise instead of a Boolean. |
* master: Update README.md Update README.md Update badges removed commented out console.log statements fixes vue-generators#358 - support "validateBeforeSubmit" with async validators # Conflicts: # src/fields/core/fieldSubmit.vue # test/unit/specs/util.js
I found two major breaks in the asynchronous validation. I reproduced both in this jsfiddle
First, if I type multiple characters into a text field, for each typed character a new validation error is displayed. Even if using
formOptions.validateDebounceTime
, which is currently not documented, multiple validation errors are displayed if I type a new character after the debounce timer and before the asynchronous validation is completed.Second, asynchronous validation errors are not included when using a submit button with the following schema:
I can still submit the form even if asynchronous validation errors are currently displayed.
The text was updated successfully, but these errors were encountered: