Skip to content

Instantly share code, notes, and snippets.

@vbalagovic
Last active September 20, 2019 10:17
Show Gist options
  • Save vbalagovic/12b378ea69032a4b08ddd358ddbc26ad to your computer and use it in GitHub Desktop.
Save vbalagovic/12b378ea69032a4b08ddd358ddbc26ad to your computer and use it in GitHub Desktop.
Handler for laravel validation errors alongside vee validate (version 2, not tested on vee validate 3.0)
// Error handler for laravel/vee validate package
$.each(errors, (key, value) => {
var field = this.$validator.fields.find({ name: key, scope: null });
if (field) {
this.$validator.errors.add({
id: field.id,
field: key,
msg: value[0],
scope: null,
});
field.setFlags({
invalid: true,
valid: false,
validated: true,
});
}
else {
this.$toastr('error', value);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment