Skip to content

MetinSeylan/Vue-Easy-Validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vue-Easy-Validator

Easy form validator, bridge of vee-validate

Install

npm install vue-easy-validator --save
import VueEasyValidator from 'vue-easy-validator'

Vue.use(VueEasyValidator)

Usage

Template

  <input v-model="form.$fields.email" type="text">
  <p v-if="form.$errors.has('email')">{{form.$errors.first('email')}}</p>
  <input v-model="form.$fields.password" type="password">
  <p v-if="form.$errors.has('password')">{{form.$errors.first('password')}}</p>

Script

new Vue({
      data(){
          return{
              form: this.$form({
                  email: {
                      rule: 'email|required',
                      value: 'imamhatipler kapatılsın' // => set default value
                  },
                  password: {
                      rule: 'required|min:3',
                      value: null
                  }
              })
          }
      },
      mounted(){
          console.log(this.form.$fields); // => Form values (dynamic)
          console.log(this.form.$rules); // => Form rules (dynamic)
          console.log(this.form.$errors); // Form errors (instance of vee-validate errorBag)
          console.log(this.$validator); // => vee-validate instance
      }
  })

About

Easy form validation plugin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published