Replies: 5 comments 2 replies
-
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.
-
Hey, I had a similar issue, I'm not sure if it's your case, but basically, all I had to do to make this work was to add a second // CustomInput.vue
useField(() => props.name, null , { validateOnValueUpdate: false }) // CustomForm.vue
const { values } = useForm({
validationSchema: props.validation
}); |
Beta Was this translation helpful? Give feedback.
-
@logaretm Hi, I am having the same issues as these gentleman. I set the You say that it is intended behaviour, that this is meant to keep the Or maybe, instead of running the silent validation for every data change to keep the |
Beta Was this translation helpful? Give feedback.
-
I kinda have the same issue... when i have a field with a validation of 9 characters for example... i dont want the use to receive a validation warning if he starts typing the first character as he still typing in the characters... i would rather have the field to validate on blur.. how can this be achieved? using the useField composable... |
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