Reputation: 297
I have been trying to use vee-validate
with scope on Veutify
form. But when the form is submitted it doesn't show any error or the form is always valid.
I think i miss something on my implementation.
Please help.
<div id="app">
<v-app id="inspire">
<form data-vv-scope="form1">
<v-text-field
v-model="name"
label="Name"
:counter="10"
:error-messages="errors.collect('form1.name')"
v-validate="'required|max:10'"
data-vv-name="name"
required
></v-text-field>
<v-btn @click.native="submit('form1')">submit</v-btn>
<v-btn @click="clear">clear</v-btn>
</form>
</v-app>
</div>
Submit Method:
submit(scope) {
alert("submit");
this.$validator.validateAll(scope).then(result => {
if (result) {
}
});
}
Upvotes: 4
Views: 1764
Reputation: 1
I think you should use validator.validate('scope.*') instead of $validator.validateAll('scope');
you may refer to this link https://vee-validate.logaretm.com/v2/api/validator.html#methods
Upvotes: 0
Reputation: 11
It is not inherently obvious from the documentation, https://baianat.github.io/vee-validate/examples/scopes.html, or from the examples provided, https://codesandbox.io/s/y3504yr0l1?from-embed, especially when using within Vuetify.
When you define data-vv-name it needs to be prefixed with the scope.
data-vv-name="form1.name"
Upvotes: 1