Skip to content

Instantly share code, notes, and snippets.

@mrv1k
Created March 23, 2018 14:55
Show Gist options
  • Save mrv1k/d95e665d72e6a282f6c0392f15e6c6e1 to your computer and use it in GitHub Desktop.
Save mrv1k/d95e665d72e6a282f6c0392f15e6c6e1 to your computer and use it in GitHub Desktop.
`veeValidate` custom mapping. Receive unmapped errors object structure and map it manually
// Receive unmapped errors object structure. More here: http://vee-validate.logaretm.com/api.html#error-bag
function mapFieldToErrorType(unmapped) {
const mapped = {};
for (const error in unmapped) {
// data-vv-name = error.rule
mapped[error] = unmapped[error][0].rule;
}
return mapped;
}
const errorList = mapFieldToErrorType(errorBag.collect('', '', false));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment