Vuelidation

simple, powerful, vuejs validation.

See the Pen Vuelidation Example by cj (@cj) on CodePen.

Install

yarn add --dev vuelidation@latest

Include Plugin

import Vue from 'vue';
import Vuelidation from 'vuelidation';

Vue.use(Vuelidation);

Use

<script>
  new Vue({
    data () {
      return {
        name: '',
      }
    },
    
    vuelidation: {
      data: {
        name: {
          required: true,
        },
      },
    },
    
    methods: {
      submit () {
        if (this.$vuelidation.valid()) {
          console.log(`Hello, ${this.name}!`)
        }
      }
    }
  })
</script>

<template>
  <form>
    <input type='text' v-model='name' />
    <div v-if='$vuelidation.error("name")'>{{ $vuelidation.error('name') }}</div>
    
    <button type="submit" :disabled="$vuelidation.errors()">Submit</button>
  </form>
</template>

GitHub