Painless forms for Vue.js
npm install vee-validate
Painless Vue forms
sh
Install with yarn
yarn add vee-validate
Install with npm
npm install vee-validate --save
`
$3
The main v4 version supports Vue 3.x only, for previous versions of Vue, check the following the table
| vue Version | vee-validate version | Documentation Link |
| ----------- | -------------------- | ---------------------------------------------------------------------------------------- |
| 2.x | 2.x or 3.x | v2 or v3 |
| 3.x | 4.x or 5.x | v4 or v5 |
$3
vee-validate offers two styles to integrate form validation into your Vue.js apps.
#### Composition API
The fastest way to create a form and manage its validation, behavior, and values is with the composition API.
Create your form with useForm and then use defineField to create your field model and props/attributes and handleSubmit to use the values and send them to an API.
`vue
`
You can do so much more than this, for more info check the composition API documentation.
#### Declarative Components
Higher-order components can also be used to build forms. Register the Field and Form components and create a simple required validator:
`vue
`
The Field component renders an input of type text` by default but you can control that