Skip to content

Commit 3d6094c

Browse files
add example to readme
1 parent 5d402d4 commit 3d6094c

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

README.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff 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
2930
To 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+
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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": {

0 commit comments

Comments
 (0)