Skip to content

Commit a3dbd08

Browse files
committed
🍜 docs: add nuxt/vee-validate
1 parent 5097028 commit a3dbd08

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

docs/_sidebar.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
- バリデーション
4545

46-
- [vee-validateを使う]()
46+
- [vee-validateを使う](nuxt/vee-validate.md)
4747

4848
- ヘルスチェック
4949

docs/nuxt/vee-validate.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## VeeValidateの使い方
2+
3+
## コンポーネントで使う場合
4+
5+
`$validator` を Inject します。
6+
7+
```javascript
8+
import { Validator } from 'vee-validator';
9+
10+
export default class extends Vue {
11+
@Inject public $validator: Validator;
12+
}
13+
```
14+
15+
## バケツリレーする系の中間コンポーネントで使う場合
16+
17+
**↑といっしょ!**
18+
19+
## pageコンポーネントで使う場合
20+
21+
`$_veeValidate` でスコープを作成する
22+
23+
```javascript
24+
@Component({
25+
$_veeValidate: {
26+
validator: 'new'
27+
}
28+
})
29+
export default class extends Vue {}
30+
```
31+
32+
## 何やってるの?
33+
34+
VeeValidate は `$_veeValidate.validate` で新しいスコープを作成することができ、
35+
36+
そのスコープ以下にあるバリデーション可能な箇所を参照できるようになるようです。
37+
38+
参照可能にするコンポーネントでは `$validator``@Inject` すれば VeeValidate を利用できます。
39+
40+
## VeeValidateのルール一覧
41+
42+
だいたいの validate が揃っているはずなので、ここから選んでください。
43+
44+
[Validation Rules | VeeValidate](https://baianat.github.io/vee-validate/guide/rules.html)
45+
46+
また、日本語に関する validate は弱いので、自作する必要があります。

0 commit comments

Comments
 (0)