Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Simple package to display error in vue from laravel validation

License

NotificationsYou must be signed in to change notification settings

val-bubbleflat/laravel-vue-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bybubbleflat.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
importLaravelVueValidatorfrom'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><inputtype='text'v-model='name'/><!--error do not need v-if,its content is displayed only if "name" has error after validation"--><errorinput="name"/><button@click="submit">Submit</button></template><script>exportdefault{data(){return{name:''}},methods(){// Error are displayed if Laravel backend return 422 Http code with name as errorthis.$http.post('/submit',{name:this.name});}}</script>

About

Simple package to display error in vue from laravel validation

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp