File tree Expand file tree Collapse file tree 2 files changed +37
-4
lines changed Expand file tree Collapse file tree 2 files changed +37
-4
lines changed Original file line number Diff line number Diff line change @@ -8,11 +8,12 @@ This package allow to display errors from laravel validation rules
8
8
9
9
# Installation
10
10
11
- ` npm install --save laravel-vue-validator `
11
+ ``` npm install --save laravel-vue-validator
12
12
13
- ` import LaravelVueValidator from 'laravel-vue-validator' `
13
+ import LaravelVueValidator from 'laravel-vue-validator'
14
14
15
- ` Vue.use(LaravelVueValidator) `
15
+ Vue.use(LaravelVueValidator)
16
+ ```
16
17
17
18
# Usage Example
18
19
@@ -29,3 +30,35 @@ This error will only be displayed if a 422 error is produced by laravel when the
29
30
To flush errors in a vue component:
30
31
31
32
` this.$errors.flush() `
33
+
34
+ # Full Example
35
+
36
+ ```
37
+ <template>
38
+ <input type='text' v-model='name' />
39
+ <!--
40
+ error do not need v-if,
41
+ its content is displayed only if "name" has error after validation"
42
+ -->
43
+ <error input="name" />
44
+ <button @click="submit">Submit</button>
45
+ </template>
46
+ <script>
47
+
48
+ export default {
49
+
50
+ data(){
51
+ return{
52
+ name: ''
53
+ }
54
+ },
55
+
56
+ methods(){
57
+ // Error are displayed if Laravel backend return 422 Http code with name as error
58
+ this.$http.post('/submit', {name: this.name});
59
+ }
60
+
61
+ }
62
+
63
+ </script>
64
+ ```
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " laravel-vue-validator" ,
3
- "version" : " 1.0.5 " ,
3
+ "version" : " 1.0.6 " ,
4
4
"description" : " Simple package to display error in vue from laravel validation" ,
5
5
"main" : " index.js" ,
6
6
"scripts" : {
You can’t perform that action at this time.
0 commit comments