From 2908c91bd0fe1e48e4ac396d27ab69485b3fa974 Mon Sep 17 00:00:00 2001 From: Damian Dulisz Date: Tue, 29 Nov 2016 16:08:58 +0100 Subject: [PATCH] Update README and main file --- README.md | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++- package.json | 2 +- 2 files changed, 81 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ba83c89e..1e649d45 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,86 @@ > Simple, lightweight model-based validation for Vue.js -## Build Setup +#### Current version: 0.1.0 + +### Features & characteristics: +* Model based +* Decoupled from templates +* Dependency free, minimalistic library +* Support for collection validations +* Support for nested models +* Contextified valdiators +* Easy to use with custom validators (e.g. Moment.js) +* Support for function composition +* Validates different data sources: Vuex getters, coumputed values, etc. + +## Demo & docs + +[http://monterail.github.io/vuelidate/](http://monterail.github.io/vuelidate/) + +## Installation + +```bash +npm install vuelidate --save +``` + +You can import the library and use as a Vue plugin to enable the functionality globally on all components containing validation configuration. + +```javascript +import Vue from 'vue' +import Validation from 'vuelidate' +Vue.use(Validation) +``` + +Alternatively it is possible to import a mixin directly to components in which it will be used. + +```javascript +import { validationMixin } from 'vuelidate' + +var Component = Vue.extend({ + mixins: [validationMixin], + validation: { ... } +}) +``` + +The browser-ready bundle is also provided in the package. + +```html + +``` + +```javascript +Vue.use(window.Validation) +``` + +## Basic usage + +For each value you want to validate, you have to create a key inside validations options. You can specify when input becomes dirty by using appropriate event on your input box. + +```javascript +import { required, minLength, between } from 'vuelidate/lib/validators' + +export default { + data () { + return { + name: '', + age: 0 + } + }, + validations: { + name: { + required, + minLength: minLength(4) + }, + age: { + between: between(20, 30) + } + } +} +``` + + +## Development Setup ``` bash # install dependencies diff --git a/package.json b/package.json index 19cb0b15..9c3ce813 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "Paweł Grabarz " ], "license": "MIT", - "main": "dist/index.js", + "main": "lib/index.js", "scripts": { "dev": "node build/dev-server.js", "bundle:web": "rm -rf dist && webpack --config build/webpack.bundle.conf.js",