laravel-vue2-validator
Advanced tools
Comparing version 0.0.8 to 0.0.9-beta-0
22
index.js
@@ -1,12 +0,8 @@ | ||
import Errors from './Errors' | ||
import Validator from './Validator' | ||
import ErrorComponent from './ErrorComponent.vue' | ||
import axios from 'axios' | ||
class Validator { | ||
install (Vue) { | ||
Vue.component('error', ErrorComponent); | ||
if (Vue.http) { | ||
@@ -16,3 +12,3 @@ Vue.http.interceptors.push((request, next) => { | ||
if (response.status === 422) { | ||
Errors.fill(response.body) | ||
Validator.fill(response.body) | ||
} | ||
@@ -22,3 +18,2 @@ }); | ||
} | ||
if (axios) { | ||
@@ -28,14 +23,12 @@ axios.interceptors.response.use((response) => { | ||
}, (error) => { | ||
if (error.response.status === 422) { | ||
Errors.fill(error.response.data.errors) | ||
const { response } = error | ||
if (response.status === 422) { | ||
const { data = {} } = response.data.errors | ||
Validator.fill(data.errors) | ||
} | ||
return Promise.reject(error); | ||
}); | ||
} | ||
Vue.mixin({ | ||
beforeCreate () { | ||
//errors | ||
this.$options.$errors = {}; | ||
@@ -50,9 +43,6 @@ Vue.util.defineReactive(this.$options, '$errors', Errors); | ||
}, | ||
}) | ||
} | ||
} | ||
export default new Validator() |
{ | ||
"name": "laravel-vue2-validator", | ||
"version": "0.0.8", | ||
"version": "0.0.9-beta-0", | ||
"description": " Simple package to display error in vue from laravel validation", | ||
"main": "index.js", | ||
"types": "types/index.d.ts", | ||
"scripts": { | ||
@@ -26,3 +27,9 @@ "test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"homepage": "https://github.com/chantouchsek/laravel-vue-validator#readme" | ||
"homepage": "https://github.com/chantouchsek/laravel-vue-validator#readme", | ||
"dependencies": { | ||
"vue": "^2.6.11" | ||
}, | ||
"devDependencies": { | ||
"axios": ">=0.15 <1.0" | ||
} | ||
} |
@@ -5,2 +5,7 @@ # Laravel Vue Validator | ||
[![Latest Version on NPM](https://img.shields.io/npm/v/laravel-vue2-validator.svg?style=flat-square)](https://npmjs.com/package/laravel-vue2-validator) | ||
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) | ||
[![npm](https://img.shields.io/npm/dt/laravel-vue2-validator.svg?style=flat-square)](https://npmjs.com/package/laravel-vue2-validator) | ||
[![npm](https://img.shields.io/npm/dm/laravel-vue2-validator.svg?style=flat-square)](https://npmjs.com/package/laravel-vue2-validator) | ||
This package allow to display errors from laravel validation rules | ||
@@ -40,10 +45,6 @@ | ||
```html | ||
```vue | ||
<template> | ||
<form action="#" @keydown="$errors.onKeydown($event)"> | ||
<form @keydown="$errors.onKeydown($event)"> | ||
<input type='text' v-model='name' :inputClass="errorClass"/> | ||
<!-- | ||
error do not need v-if, | ||
its content is displayed only if "name" has error after validation" | ||
--> | ||
<error input="name" /> | ||
@@ -56,3 +57,2 @@ <button @click="submit">Submit</button> | ||
export default { | ||
data(){ | ||
@@ -64,12 +64,8 @@ return{ | ||
}, | ||
methods(){ | ||
// Error are displayed if Laravel backend return 422 Http code with name as error | ||
this.$http.post('/submit', {name: this.name}); | ||
}, | ||
destroyed () { | ||
// Errors will be clear after component destroyed | ||
this.$errors.flush() | ||
} | ||
} | ||
@@ -76,0 +72,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9328
8
231
1
1
71
1
+ Addedvue@^2.6.11
+ Added@babel/helper-string-parser@7.25.9(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@babel/parser@7.26.3(transitive)
+ Added@babel/types@7.26.3(transitive)
+ Added@vue/compiler-sfc@2.7.16(transitive)
+ Addedcsstype@3.1.3(transitive)
+ Addednanoid@3.3.8(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedpostcss@8.4.49(transitive)
+ Addedprettier@2.8.8(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsource-map-js@1.2.1(transitive)
+ Addedvue@2.7.16(transitive)