Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/cj/vuelidation

simple, powerful, vuejs validation.
https://github.com/cj/vuelidation

form validation vue vuejs vuejs2

Last synced: 3 months ago
JSON representation

simple, powerful, vuejs validation.

Awesome Lists containing this project

README

        

Vuelidation ✅


simple, powerful, vuejs validation.


Build Status
Coverage Status
Downloads
Gitter
License


Example

**Install**

`yarn add --dev vuelidation@latest`

**Include Plugin**
```javascript
import Vue from 'vue';
import Vuelidation from 'vuelidation';

Vue.use(Vuelidation);
```
**Use**
```vue

new Vue({
data () {
return {
name: '',
}
},

vuelidation: {
data: {
name: {
required: true,
},
},
},

methods: {
submit () {
if (this.$vuelidation.valid()) {
console.log(`Hello, ${this.name}!`)
}
}
}
})



{{ $vuelidation.error('name') }}


Submit

```

## Validations

alphabetic



  • Must be a alphabetic value


  • args: Boolean


```javascript
{
alphabetic: true,
}
```

alpha



  • Must only contain letters and numbers


  • args: Boolean


```javascript
{
alpha: true,
}
```

alphaDash




  • msg: Must only contain letters, numbers, underscores or dashes


  • arg: Boolean


```javascript
{
alphaDash: true,
}
```

alphaSpace




  • msg: Must only contain letters, numbers or spaces


  • arg: Boolean


```javascript
{
alphaSpace: true,
}
```

length




  • msg: Must be {{ length }} character(s)


  • arg: Number


```javascript
{
length: 16,
}
```

between




  • msg: Must be between {{ min }} and {{ max }}


  • arg: { min: Number, max: Number }


```javascript
{
between: {
min: 5,
max: 10,
},
}
```

betweenLength




  • msg: Must have between {{ min }} and {{ max }} characters


  • arg: { min: Number, max: Number }


```javascript
{
betweenLength: {
min: 8,
max: 20,
},
}
```

decimal




  • msg: Must be a decimal<% if (points && points !== "*") { %> with {{ points }} points<% } %>


  • arg: { points: *Number }


```javascript
{
decimal: {
points: 2,
},
}
```

email




  • msg: Not a valid email


  • arg: Boolean


```javascript
{
email: true,
}
```

includes




  • msg: {{ value }} is not one of the following: {{ values.join(", ") }}


  • arg: { includes: Array }


```javascript
{
includes: ['foo', 'bar'],
}
```

numeric




  • msg: Must be a numeric value


  • arg: Boolean


```javascript
{
numeric: true,
}
```

required




  • msg: Required


  • arg: Boolean


```javascript
{
required: true,
}
```

* - the **arg** is optional.