Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit 3da209a

Browse files
authored
Merge pull request #71 from agoalofalife/master
update doc validate Method
2 parents 6b4d472 + 938c994 commit 3da209a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

en/api/pages-validate.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ description: Nuxt.js lets you define a validator method inside your dynamic rout
1010
- **Type:** `Function`
1111

1212
```js
13-
validate({ params, query }) {
13+
validate({ params, query, store }) {
1414
return true // if the params are valid
1515
return false // will stop Nuxt.js to render the route and display the error page
1616
}
@@ -28,3 +28,14 @@ export default {
2828
}
2929
}
3030
```
31+
32+
You can also check some data in your [store](/guide/vuex-store) for example (filled by [nuxtServerInit action](/guide/vuex-store#the-nuxtserverinit-action) before):
33+
34+
```js
35+
export default {
36+
validate ({ params, store }) {
37+
  // Check if `params.id` is an existing category
38+
  return store.state.categories.some((category) => category.id === params.id)
39+
}
40+
}
41+
```

0 commit comments

Comments
 (0)