Validate Forms in Vue JS
In this tutorial about ¿How to validate forms, fields or inputs in Vue?, we are going to make use of one of my npm packages, which is called @elpandev/laravel-validator
and contains most of the rules that Laravel uses to validate forms.
Form in Vue
Before validating, we are going to create a form with the name and description fields, which will be found inside an html form and a prevent method called validate.
Additionally, we are going to create the validate method to validate the form fields.
Form Validation
Now that we have our Vue component ready, we are going to leave the fields empty and validate our form, obtaining as a result 2 errors that match the "required" rule that we have added for each field.
If you want to know more about the rules that this package contains, I recommend you review the Laravel validation rules, due to these rules are the same than this plugin contains but in typescript.