I have successfully implemented form validation using Vue 3, vee-validate, and yup schema. However, I am facing an issue when trying to validate errors returned from the server, such as a duplicated email. While setting custom error messages like this works fine:
form.value.setErrors({
email: 'my error message'
});
I want to be able to loop through my array of errors to display the fields (param) and corresponding error messages (msg). The challenge lies in defining the param dynamically within setErrors () function:
for (const error of errors.response.data.errors) {
let param = error.param;
let msg = error.msg;
form.value.setErrors({
param: msg
});
}
My goal is to iterate through "errors.response.data.errors" and use dynamically defined param and msg variables with setErrors ().