Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

laravel-vue2-validator

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

laravel-vue2-validator

Simple package to display error in vue from laravel validation

  • 0.0.9-beta-13
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23
increased by64.29%
Maintainers
1
Weekly downloads
 
Created
Source

Laravel Vue Validator

By bookingkh.com

Latest Version on NPM Software License npm npm

This package allow to display errors from laravel validation rules

! This package needs axios or vue-resource to work !

Installation

npm install --save laravel-vue2-validator
import LaravelVueValidator from 'laravel-vue2-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>
	<form @keydown="$errors.onKeydown($event)">
	    <input type='text' v-model='name' :inputClass="errorClass"/>
    	<error input="name" />
    	<button @click="submit">Submit</button>
</form>
</template>
<script>

export default {
	data(){
		return{
			name: '',
			errorClass: 'form-error'
		}
	},
	methods(){
		this.$http.post('/submit', {name: this.name});
	},
     destroyed () {
       this.$errors.flush()
     }
}

</script>

Keywords

FAQs

Package last updated on 03 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc