Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-validity

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-validity

Simple, powerful and flexible model-based Vue.js validation library

  • 0.2.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

vue-validity

A simple, powerful and flexible validation library for Vue.js 2.0.

Features

  • Model-based validation.
  • Validate custom components.
  • Set custom errors (eg. server-side errors) via $setErrors.
  • Create custom validators along with custom errors messages.
  • Automatically adds input classes based on state (eg. 'dirty', 'invalid', etc.)

Installation

npm install --save vue-validity

import Vue from 'vue'
import Validity from 'vue-validity'

// Optionally provide configuration options.
Vue.use(Validity, {})

Basic usage

For each value you want to validate, you have to create a key inside validations options.

export default {
  data () {
    return {
      name: ''
    }
  },
  validations: {
    name: ['required', 'minlength:4']
  }
}

This will result in the following validation object:

$v: {
  "name": {
    "required": {
      "$value": false,
      "$message": "name is required."
    },
    "minlength": {
      "$value": true,
      "$message": "name should be at least 4 chars."
    },
    "$valid": false,
    "$dirty": false,
    "$error": false,
    "$errors": []
  },
  "$valid": false,
  "$dirty": false,
  "$error": false,
  "$errors": []
}

Checkout the docs for more examples: https://jrenton.github.io/vue-validity/

Contributing

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build

License

MIT

Original vuelidate work Copyright (c) 2016 Paweł Grabarz & Damian Dulisz

Keywords

FAQs

Package last updated on 29 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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