Vuelidate-forms
Combine data object and validation schema in one declaration
Vuelidate docs
Installation
- Install vuelidate and vuelidate-forms
npm install vuelidate vuelidate-forms
- Import and write Vue.use
VueVue
Important: you should connect VuelidateForms before Vuelidate.
Usage
Default fields
forms: test: field: required anotherField: required numeric
Is equal to
data: test: field: null anotherField: null validations: test: field: required anotherField: required numeric
Fields with default value
forms: test: field: 'test' anotherField: required numeric $value: 5
Is equal to
data: test: field: 'test' anotherField: 5 validations: test: anotherField: required numeric
Array validation
forms: test: list: minLength: $each: field: required anotherField: required numeric
Is equal to
data: test: list: validations: test: list: minLength: $each: field: required anotherField: required numeric
TODO:
- Finish plugin
- Write tests