How to validate Vuetify text field asynchronously?
One solution is to set the error-messages
prop:
<v-text-field v-model="input" :error-messages="errors">
and use the watch
option:
new Vue({
data () {
return {
input: '',
errors: []
}
},
watch: {
input (val) {
axios.get('/check?value=' + val).then(valid => {
this.errors = valid ? [] : ['async error']
})
}
}
});