Vee Validate for Laravel backend validation
Simple vue js plugin that makes it easier to show validation errors from Laravel validation by using vee-validate.
Getting Started
In your script entry point:
;;; Vue;Vue;
From Laravel:
$request->validate([ 'name' => 'required|min:3|max:255']);
In Vue classes:
<template> <div class="form-group" v-bind:class="{'has-error' : errors.has('name')}"> <label for="name">Name</label> <input type="text" name="name" class="form-control" v-model="name" v-validate="'required'" /> <div v-show="errors.has('name')" class="help-block">{{ errors.first('name') }}</div> </div></template> <script> export default { methods: { doValidation() { const data = { name: this.name }; axios.post('/example', data).then(res => { }).catch(err => { this.$setLaravelValidationErrorsFromResponse(err.response.data); }); } } }</script>