Created
August 1, 2019 21:18
-
-
Save shotasenga/433e865ebda2cdc452403c2ad1a0590a to your computer and use it in GitHub Desktop.
Vuelidate list all errors
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
function findErrors($v, prefix = "", flat = []) { | |
Object.keys($v) | |
.filter(k => $v[k].$invalid || $v[k] === false) | |
.forEach(k => { | |
if (typeof $v[k] === "boolean") { | |
flat.push(prefix + "." + k) | |
} else { | |
return findErrors($v[k], `${prefix}.${k}`, flat) | |
} | |
}) | |
return flat | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
on the dev-tool console, run
findErrors($vm.$v)
.