# @pmochine/vee-validate-laravel

> Adds simple laravel form validation support to vee-validate

Latest version **1.0.6** (published 2020-03-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @pmochine/vee-validate-laravel
pnpm add @pmochine/vee-validate-laravel
yarn add @pmochine/vee-validate-laravel
bun add @pmochine/vee-validate-laravel
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2020-03-17 |
| First published | 2019-02-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Philipp Mochine |
| Maintainers | pmochine |
| Keywords | vee-validate, laravel, validator |

## Links

- npm: https://www.npmjs.com/package/@pmochine/vee-validate-laravel
- Repository: https://github.com/pmochine/vee-validate-laravel
- Homepage: https://github.com/pmochine/vee-validate-laravel#readme
- Issues: https://github.com/pmochine/vee-validate-laravel/issues
- npm.io page: https://npm.io/package/@pmochine/vee-validate-laravel

## Alternatives

- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads

## Recent versions

- 1.0.6 (latest) — 2020-03-17
- 1.0.5 — 2019-02-09
- 1.0.4 — 2019-02-09
- 1.0.3 — 2019-02-09
- 1.0.2 — 2019-02-09
- 1.0.1 — 2019-02-09
- 1.0.0 — 2019-02-09

## README

# 🙌 VeeValidate with Laravel validation errors
[![Latest Version on NPM](https://img.shields.io/npm/v/%40pmochine%2Fvee-validate-laravel.svg?style=flat-square)](https://npmjs.com/package/%40pmochine%2Fvee-validate-laravel)
[![Total Downloads on NPM](https://img.shields.io/npm/dt/%40pmochine%2Fvee-validate-laravel.svg)](https://www.npmjs.com/package/%40pmochine%2Fvee-validate-laravel)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)

![VeeValidate with Laravel validation](https://baianat.github.io/vee-validate/logo.png)

**If you are looking for an easy module for showing Laravel validation errors, this package is for you. 😜**

>***Prerequisites**:  vue >= 2.0.0 and vee-validate >= 2.1.0

*⚠️ Combine this package with a [global axios interceptor](https://github.com/pmochine/vue-axios-interceptors) to get the most of it*

## Installation in 2 Steps*

### 1: Install the package 💻 on [NPM](https://www.npmjs.com/package/@pmochine/vee-validate-laravel)
```bash
npm i @pmochine/vee-validate-laravel
```
### 2: Add the package in your main.js

```javascript
import Vue from 'vue';
import VeeValidate from 'vee-validate';
import VeeValidateLaravel from '@pmochine/vee-validate-laravel';

Vue.use(VeeValidate);
Vue.use(VeeValidateLaravel);
```


## 💪 How to use it

Somewhere in Laravel:

```php
$request->validate([
    'name' => 'required|min:3|max:255'
]);

```


Somewhere in Vue:


```vue
<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 => {
                        //adds errors to vee-validate errorBag and returns the errors as object
                        const errors = this.$addLaravelErrors(err.response);

                        if(errors){
                            alert(errors[Object.keys(errors)[0]]); 
                        }
                    });
            }
        }
    }
</script>
```

## Security

If you discover any security related issues, please don't email me. I'm afraid 😱. avidofood@protonmail.com

## Credits

Now comes the best part! 😍

 - Idea found on https://github.com/RobertGlynWilliams/vee-validate-laravel

Oh come on. You read everything?? If you liked it so far, hit the ⭐️ button to give me a 🤩 face.

---
_Source: https://npm.io/package/@pmochine/vee-validate-laravel · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
