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
88
99# Installation
1010
11- ` npm install --save laravel-vue-validator `
11+ ``` npm install --save laravel-vue-validator
1212
13- ` import LaravelVueValidator from 'laravel-vue-validator' `
13+ import LaravelVueValidator from 'laravel-vue-validator'
1414
15- ` Vue.use(LaravelVueValidator) `
15+ Vue.use(LaravelVueValidator)
16+ ```
1617
1718# Usage Example
1819
@@ -29,3 +30,35 @@ This error will only be displayed if a 422 error is produced by laravel when the
2930To flush errors in a vue component:
3031
3132 ` 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 11{
22 "name" : " laravel-vue-validator" ,
3- "version" : " 1.0.5 " ,
3+ "version" : " 1.0.6 " ,
44 "description" : " Simple package to display error in vue from laravel validation" ,
55 "main" : " index.js" ,
66 "scripts" : {
You can’t perform that action at this time.
0 commit comments