Text fields in Vuetify have rules
props, which take an array of functions returning true
or an error string. How to make them async, so that the validation could be made server-side using XHR?
Something like:
<v-text-field :rules="[v => { axios.get('/check?value=' + val).then(() => { return true }) }]">
One solution is to set the
error-messages
prop:<v-text-field v-model="input" :error-messages="errors">
and use the
watch
method:I have to do a backend validation to check if the username entered already exists. I use the swagger client library with the JSON open API v3 to call the method that checks the username value.
So I solved in this way...
In my login.js file I have defined a string property that contains the error message:
Then in the Login.vue file I have this code:
In this way it seems to work well