Form validation
Throughout the book, we've looked at various different ways that we can capture user input with the likes of v-model. We'll be using a third-party library named Vuelidate to perform model validation depending on a particular ruleset. Let's create a playground project by running the following in your Terminal:
# Create a new Vue project $ vue init webpack-simple vue-validation # Navigate to directory $ cd vue-validation # Install dependencies $ npm install # Install Vuelidate $ npm install vuelidate # Run application $ npm run dev
What is Vuelidate?
Vuelidate is an open source, lightweight library that helps us perform model validation with a variety of validation contexts. Validation can be functionally composed and it also works well with other libraries such as Moment, Vuex, and more. As we've installed it in our project with npm install vuelidate, we now need to register it as a plugin within main.js:
import Vue from 'vue'; import Vuelidate from 'vuelidate'; import App...