Fix validate in children

This commit is contained in:
Sébastien Chopin 2016-12-20 18:05:27 +01:00
parent 37e7a01955
commit f335c8bd03
2 changed files with 10 additions and 6 deletions

View File

@ -80,9 +80,11 @@ function render (to, from, next) {
this.setTransitions(mapTransitions(Components, to, from))
this.error()
let nextCalled = false
let isValid = Components.some((Component) => {
if (typeof Component.options.validate !== 'function') return true
return Component.options.validate({
let isValid = true
Components.forEach((Component) => {
if (!isValid) return
if (typeof Component.options.validate !== 'function') return
isValid = Component.options.validate({
params: to.params || {},
query: to.query || {}
})

View File

@ -74,9 +74,11 @@ export default context => {
return Component
})
// Call .validate()
let isValid = Components.some((Component) => {
if (typeof Component.options.validate !== 'function') return true
return Component.options.validate({
let isValid = true
Components.forEach((Component) => {
if (!isValid) return
if (typeof Component.options.validate !== 'function') return
isValid = Component.options.validate({
params: context.route.params || {},
query: context.route.query || {}
})