Skip to content

Deadsimple-ecommerce/VuelidateLibrary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Latest Stable Version Total Downloads License

Deadsimple Vuelidate Magento2 Composer Library

Implement modern form validation to your Magento 2 VueJS forms using vuelidate

Installation

Use composer to install the module: composer require deadsimple/vuelidatelibrary

Usage

To use Vuelidate you will need to load the Vuelidate library and it's Validators using the Magento 2 requirejs methods. Select the neccesary mixin and the validators you would like to use with the destructure syntax. Load the mixin like any other mixins and start using Vuelidate as described in it's documentation.

define([
    'Vue',
    'Vuelidate',
    'VuelidateValidators',
], function (Vue, Vuelidate, validators) {

    const {validationMixin} = Vuelidate;
    const {required, email } = validators;
    
    Vue.component('contactForm', {
        template: template,
        mixins: [ validationMixin ],
        data() {
          return { 
            name: null,
            email: null, 
          }
        },
        validations(){ 
          name: { required },
          email: { required, email }
        }
    })
})

Version

This library loads: Vuelidate v0.7.5