Created
March 23, 2018 14:55
-
-
Save mrv1k/d95e665d72e6a282f6c0392f15e6c6e1 to your computer and use it in GitHub Desktop.
`veeValidate` custom mapping. Receive unmapped errors object structure and map it manually
This file contains hidden or 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
// 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