Home

Issue: 2130

Validate several pages with similar routes

[issue link]

Hi! I want to add several pages with similar routes. A page should be displayed that suits the conditions in asyncData or validate.

Example:

# _foo.vue - only digits
export default {
  validate ({ params }) {
    return /^\d+$/.test(params.foo)
  }
}
# _bar.vue - only something else
export default {
  asyncData ({ params, error }) {
    return checkParams(params)
      .catch((e) => {
        # go to check next route
      })
  }
}

# _other.vue - for other params
export default {
}

Of course, I can make a general check in one file. But is it possible to implement it in several pages?
Can this be seen as a task for the future?

This question is available on Nuxt.js community (#c1887)