Validate before update in component?
bryanbuchs opened this issue · 2 comments
I'm trying to validate input (w/ vuelidate) and need to stop a commit from happening if it fails. I see where I can write a custom mutation, but that doesn't have access to the validation object I need.
Is there component-level access to override the computed get/set methods?
@bryanbuchs The examples show how you can build your own custom mutation. I'm not sure what you mean by component-level access
– I guess you mean access to the Vue instance? I haven't found a way to make the Vue instance available in mutations other than by passing it in as a parameter, which isn't viable with Vuex-map-fields
Maybe the way to go is to add a watch to track Vuelidate (i.e. watch $v.$invalid
) and write its value to the vuex state somewhere. Once it's in the state then you have access to that value in your mutation.
Closing this as there's been no further feedback from the OP