Skip to content

Commit

Permalink
Update README and main file
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian Dulisz committed Nov 29, 2016
1 parent c7876e2 commit 2908c91
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 2 deletions.
81 changes: 80 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<script src="vuelidate/dist/vuelidate.min.js"></script>
```

```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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"Paweł Grabarz <pawel.grabarz@monterail.com>"
],
"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",
Expand Down

0 comments on commit 2908c91

Please sign in to comment.