vuelidate vs @formkit/vue
Vue.js Form Validation Libraries Comparison
1 Year
vuelidate@formkit/vueSimilar Packages:
What's Vue.js Form Validation Libraries?

Form validation libraries in Vue.js help developers ensure that user input is accurate, complete, and secure. They provide mechanisms to validate form fields, manage form state, and give feedback to users. These libraries can significantly enhance user experience by preventing submission of invalid data and providing real-time validation feedback. Choosing the right library depends on the specific needs of the project, such as simplicity, flexibility, or advanced validation features.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
vuelidate156,3106,906104 kB2113 years agoMIT
@formkit/vue52,3784,4491.74 MB1775 months agoMIT
Feature Comparison: vuelidate vs @formkit/vue

Validation Approach

  • vuelidate:

    Vuelidate employs a reactive approach to validation, where validation rules are defined as JavaScript objects. This allows for dynamic validation that can change based on user input, providing a more programmatic way to handle validations.

  • @formkit/vue:

    @formkit/vue offers a declarative approach to validation, allowing developers to define validation rules directly in the template. It supports both synchronous and asynchronous validations, making it suitable for complex scenarios such as API calls for unique field checks.

Customization

  • vuelidate:

    Vuelidate is less focused on UI components and more on validation logic. While it allows for some customization, it is primarily used in conjunction with other UI libraries, making it less flexible in terms of UI design.

  • @formkit/vue:

    @formkit/vue is designed for high customization, enabling developers to create custom input components and validation rules. It provides a rich API for styling and behavior, making it suitable for applications that require a unique look and feel.

Learning Curve

  • vuelidate:

    Vuelidate is relatively easy to learn, especially for developers familiar with Vue's reactivity. Its straightforward API and integration with Vue make it accessible for quick implementation of validation.

  • @formkit/vue:

    @formkit/vue has a moderate learning curve due to its extensive features and customization options. Developers may need to invest time in understanding its API and how to leverage its full potential for complex forms.

Community and Support

  • vuelidate:

    Vuelidate has been around for a while and has a solid community backing. It is well-documented, making it easy for developers to find examples and support for common validation scenarios.

  • @formkit/vue:

    @formkit/vue has a growing community and is actively maintained, providing good documentation and support. Its modern approach attracts developers looking for innovative solutions in form handling.

Integration

  • vuelidate:

    Vuelidate integrates smoothly with Vue's reactivity system, making it easy to use alongside Vue components. It can be combined with various UI libraries, although it may require additional setup for complex forms.

  • @formkit/vue:

    @formkit/vue integrates well with Vue 3 and supports Composition API, making it a great choice for modern Vue applications. Its design is optimized for seamless integration with other Vue libraries and tools.

How to Choose: vuelidate vs @formkit/vue
  • vuelidate:

    Choose Vuelidate if you prefer a lightweight and straightforward validation solution that integrates seamlessly with Vue's reactivity system. It is suitable for projects that require simple validation rules without the overhead of a full-fledged form library.

  • @formkit/vue:

    Choose @formkit/vue if you need a highly customizable and flexible form library that supports complex validation scenarios and offers a rich set of UI components. It is ideal for projects requiring extensive form handling capabilities and a modern design approach.

README for vuelidate

vuelidate

codecov gzip size

Simple, lightweight model-based validation for Vue.js

Sponsors

Gold

Vuejs Amsterdam

Vue - The Road To Enterprise

Silver

Storyblok

Bronze

Vue Mastery logo Vue Mastery logo

Features & characteristics:

  • Model based
  • Decoupled from templates
  • Dependency free, minimalistic library
  • Support for collection validations
  • Support for nested models
  • Contextified validators
  • Easy to use with custom validators (e.g. Moment.js)
  • Support for function composition
  • Validates different data sources: Vuex getters, computed values, etc.

Demo & docs

https://vuelidate.js.org/

Vue 3 support

Vue 3 support is almost here with the Vuelidate 2 rewrite. Check out the next branch to see the latest progress.

Installation

npm install vuelidate --save

You can import the library and use as a Vue plugin to enable the functionality globally on all components containing validation configuration.

import Vue from 'vue'
import Vuelidate from 'vuelidate'
Vue.use(Vuelidate)

Alternatively it is possible to import a mixin directly to components in which it will be used.

import { validationMixin } from 'vuelidate'

var Component = Vue.extend({
  mixins: [validationMixin],
  validations: { ... }
})

The browser-ready bundle is also provided in the package.

<script src="vuelidate/dist/vuelidate.min.js"></script>
<!-- The builtin validators is added by adding the following line. -->
<script src="vuelidate/dist/validators.min.js"></script>
Vue.use(window.vuelidate.default)

Basic usage

For each value you want to validate, you have to create a key inside validations options. You can specify when input becomes dirty by using appropriate event on your input box.

import { required, minLength, between } from 'vuelidate/lib/validators'

export default {
  data () {
    return {
      name: '',
      age: 0
    }
  },
  validations: {
    name: {
      required,
      minLength: minLength(4)
    },
    age: {
      between: between(20, 30)
    }
  }
}

This will result in a validation object:

$v: {
  name: {
    "required": false,
    "minLength": false,
    "$invalid": true,
    "$dirty": false,
    "$error": false,
    "$pending": false
  },
  age: {
    "between": false
    "$invalid": true,
    "$dirty": false,
    "$error": false,
    "$pending": false
  }
}

Checkout the docs for more examples: https://vuelidate.js.org/

Contributing

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# create UMD bundle.
npm run build

# Create docs inside /gh-pages ready to be published
npm run docs

# run unit tests
npm run unit

# run all tests
npm test

For detailed explanation on how things work, checkout the guide and docs for vue-loader.

Contributors

Current

Damian Dulisz
Damian Dulisz
Natalia Tepluhina
Natalia Tepluhina
Natalia Tepluhina
Dobromir Hristov
Marina Mosti
Marina Mosti

Emeriti

Here we honor past contributors who have been a major part on this project.

License

MIT