Last active
September 20, 2019 10:17
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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