deadsimple/vuelidatelibrary

A deadsimple module to use Vuelidate in your Modern Magento 2 Vue Projects

Installs: 3 861

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Language:JavaScript

Type:magento2-module

1.0.2 2020-09-30 13:03 UTC

This package is auto-updated.

Last update: 2024-04-29 04:40:15 UTC


README

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