Skip to content

Instantly share code, notes, and snippets.

@shotasenga
Created August 1, 2019 21:18
Show Gist options
  • Save shotasenga/433e865ebda2cdc452403c2ad1a0590a to your computer and use it in GitHub Desktop.
Save shotasenga/433e865ebda2cdc452403c2ad1a0590a to your computer and use it in GitHub Desktop.
Vuelidate list all errors
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
}
@shotasenga
Copy link
Author

on the dev-tool console, run findErrors($vm.$v).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment