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 - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9-beta-0

types/index.d.ts

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 @@

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