Coder Social home page Coder Social logo

vue-validator-1's Introduction

vue-validator

form validator for vue 0.11

usage:

var Vue = require('vue')
var validator = require('vue-validator')
Vue.use(validator)

in template

<input type="text" v-model="name" v-valid="required,minLength:3,alpha">

means.. name is required, must be at least 3 character length and only alphabetic characters. If all this rules are satisfied input will get valid class otherwise invalid. Validator status is held in vm.validator. See demo.js for more examples of usage.

For custom elements you can specify model name in additional attribute model.

<xcomponent model="name" v-valid="required"></xcomponent>

v-valid options:

  • required
  • numeric
  • integer
  • digits
  • alpha
  • alphaNum
  • email
  • url
  • minLength: min string length
  • maxLength: max string length
  • length: string length
  • min: number value
  • max: number value
  • pattern: regex
  • group: group name

You can add additional filters to Vue.util.validators

validator data:

  • valid - input is valid
  • modified - input is modified (current value != start value)
  • invalid - modified and invalid

methods added to VM:

  • $valid([group]) - return if true if form is valid (group is optional)
  • $modified([group]) - return if true if form is modified (group is optional)

DEMO

http://xrado.github.io/vue-validator/

TODO

  • may still need some tweaking
  • tests

License

MIT

Copyright (c) 2014 Radovan Lozej

vue-validator-1's People

Contributors

xrado avatar franciscolourenco avatar

Watchers

yunchuan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.