laravel-vue-validator

Simple package to display error in vue from laravel validation
1,209 31
Install
npm install laravel-vue-validator
Latest Version:1.0.7
License:MIT
Last Updated:Apr 11, 2019
Links: GitHub  ·  npm
Maintainer: val-bubbleflat

Laravel Vue Validator

By bubbleflat.com

This package allow to display errors from laravel validation rules

! This package needs vue-resource to work !

Installation

npm install --save laravel-vue-validator
import LaravelVueValidator from 'laravel-vue-validator'
  
Vue.use(LaravelVueValidator)

Usage Example

If you have in your laravel validation rule :

'name' => 'required|min:2|max:20'

You can display the error using in vue :

<error input="name" />

This error will only be displayed if a 422 error is produced by laravel when the form is submited (when the rule is not satisfied)

To flush errors in a vue component:

this.$errors.flush()

Full Example

<template>
	<input type='text' v-model='name' />
	<!-- 
	error do not need v-if,
	its content is displayed only if "name" has error after validation"
	-->
	<error input="name" />
	<button @click="submit">Submit</button>
</template>
<script>

export default {

	data(){
		return{
			name: ''
		}
	},

	methods(){
		// Error are displayed if Laravel backend return 422 Http code with name as error
		this.$http.post('/submit', {name: this.name});
	}

}

</script>

Related Packages

vform

Handle Laravel-Vue forms and validation with ease.

163,759 600
vue-valid8

A simple form validation package made for Vue.js.

1,440 3
vue-lite-validator

Simple Vue.js input validation plugin

579 0
@retailcrm/vue-formulario

Vue Formulario is a library, inspired by Vue Formulate , that handles the core l...

86,689 3

Version History

Version Released License
1.0.7 MIT
1.0.6 MIT
1.0.5 MIT
1.0.4 MIT
1.0.3 MIT