Replies: 2 comments 1 reply
-
Same question here, can´t change the validation behavior at all |
Beta Was this translation helpful? Give feedback.
-
In my current organization, we defined the following simple workaround for this issue.By default, vee-validate runs validation whenever the value ref changes whether it was bound by a v-model or changed in the code. It can be disabled by passing a validateOnValueUpdate option set to false. (https://vee-validate.logaretm.com/v4/guide/composition-api/custom-inputs/#validating-with-functions)
However, this configuration does not work as expected. Even when validateOnValueUpdate is set to 'false', validation always runs silently and valid flag is updated. The above mentioned configuration only prevents error message from being set after the validation is run. This is problematic is a few ways: In Asynchronous validation scenarios (that field validation is done asynchronously by backend e.g. equipment id field), asynchronous validation is continuously running silently on every single value change. To overcome this limitation, it's recommended to introduce an additional ref to determine if validation is triggered by intended validation trigger or silently. If the intended validation trigger is onBlur event, it is expected to set the ref to 'true' to inform validator to recognize this as real validation trigger. Validation function is expected to check first of all whether the current validation cycle is the real validation or silent validation. If it is realValidation, it sets the ref back to 'false' and runs the validation. If it is not the real validation, it return false. This effectively keeps the valid flag to 'false' for all silent validations. As silent validation does not set error messages, this works perfectly fine. `async function fieldValidator(value: string) { //Validation logic to come here |
Beta Was this translation helpful? Give feedback.
-
o/
I just want them to be validated by @blur please help 😞
"validateOnValueUpdate: false" worked before I implemented the scheme, but now it doesn't.
Template code.
js code:
According to the documentation, I also tried to use handleChange to prevent validation by @change, but q-input does not have such an event, so I tried to hang it on @update: model-value. And it's not working 😭
Beta Was this translation helpful? Give feedback.
All reactions