There is a cleaner way then using ref's to lookup if the plugin added a class.
Instead of having a top-level model for every form input username, password etc make a form model which contains errors and values which encapsulate that form.
Then upon validation, set this.form.errors[theField] with the error, then that error will be applied to :danger-text and :danger="form.errors.password".
It will also make the error handling from serverside much easier as you simply plop errors back into the model.
For example:
data: () => ({
form: {
errors: {},
values: {
username:'',
password: ''
}
}
}),
methods: {
submit() {
this.form.errors = {}
if (!this.form.values.password) {
this.form.errors.password = 'Password is a required field.'
} else if (...) {
...
}
if (Object.keys(this.form.errors).length) return
// some ajax call
ajax.post(..).then((res) => {
if (res.errors) {
this.form.errors = res.errors
} else {
}
}).catch(e => {
// maybe set global alert
})
}
<vs-input label="Password"
v-model="form.values.password"
:danger-text="form.errors.password"
:danger="form.errors.password" />
classList?