vue-convenia-validator
| Install | |
|---|---|
npm install vue-convenia-validator |
|
| Latest Version: | 0.1.54 |
| Vue: | 2 |
| License: | MIT |
| Last Updated: | May 13, 2021 |
| Links: | npm |
vue-convenia-validator
vue-convenia-validator is a model-based form validation library for Vue.js inspired by Vuelidate and VeeValidate. Unlike Vuelidate and VeeValidate, vue-convenia-validator is meant to be used as a mixin rather than as a plugin.
Installation
npm
npm install vue-convenia-validator --save
yarn
yarn add vue-convenia-validator
Usage
vue-convenia-validator is a model-based, template-independent validation library,
which means that it is completely decoupled from how you build your templates.
In order to use your component has to define a validation option object
defining the validation rules for your form(s):
<template>
<div id="vue-app">
<form>
<input name="fullName" type="text" v-model="fullName" />
<input name="birthday" type="text" v-model="birthday" />
</form>
</div>
<template>
<script>
import FormValidator from 'cee-validate'
export default {
mixins: [ FormValidator ],
data () {
return {
fullName: '',
birthday: ''
}
}
validations: {
fullName: 'required',
birthday: 'required|date_format:DD/MM/YYYY'
}
}
<script>
The name attribute on the <input /> fields here is necessary for the mixin
to be able to listen for certain events on the form elements. The name
attribute is only necessary on the <form> tag when using scoped forms:
<template>
<div id="vue-app">
<form name="formOne">
<input name="fullName" type="text" v-model="formOne.fullName" />
<input name="birthday" type="text" v-model="formOne.birthday" />
</form>
<form name="formTwo">
<input name="fullName" type="text" v-model="formTwo.fullName" />
<input name="birthday" type="text" v-model="formTwo.birthday" />
<input name="age" type="number" v-model="formTwo.age" />
</form>
</div>
<template>
<script>
import FormValidator from 'cee-validate'
export default {
mixins: [ FormValidator ],
data () {
return {
formOne: {
fullName: '',
birthday: ''
},
formTwo: {
fullName: '',
birthday: ''
}
}
}
validations: {
formOne: {
fullName: 'required',
birthday: 'required|date_format:DD/MM/YYYY'
},
formTwo: {
fullName: 'required',
birthday: 'required|date_format:DD/MM/YYYY'
age: 'numeric'
}
}
}
<script>
To-do
-
Implement rules
- alphanumeric - Checks if all characters in a string are alphanumeric.
- custom - Executes a callback or array of callbacks with input value as argument.
- dateFormat - Checks if value is a valid date.
- numeric - Check if all characters in a string are numbers.
- regex - Tests a RegExp on value.
- required - Checks if value isn't empty.
- hour - Checks if value is a valid hour
- dateBetween - Checks if date is in between two date values.
- dateBefore - Checks if given date comes before another date.
- dateAfter - Checks if given date comes after another date.
- email - Checks if value is a valid email address.
- url - Checks if value is a valid URL address.
- ip - Checks if value is a valid IP address.
- creditCard - Checks if value is a valid credit card number.
-
Implement unit tests
-
Improve project documentation
-
Implement option to customize validation error messages
-
Implement Vue directive
Related Packages
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 0.1.54 | ^2.5.17 | MIT | |
| 0.1.53 | ^2.5.17 | MIT | |
| 0.1.52 | ^2.5.17 | MIT | |
| 0.1.51 | ^2.5.17 | MIT | |
| 0.1.50 | ^2.5.17 | MIT | |
| 0.1.49 | ^2.5.17 | MIT | |
| 0.1.48 | ^2.5.17 | MIT | |
| 0.1.47 | ^2.5.17 | MIT | |
| 0.1.46 | ^2.5.17 | MIT | |
| 0.1.45 | ^2.5.17 | MIT | |
| 0.1.44 | ^2.5.17 | MIT | |
| 0.1.43 | ^2.5.17 | MIT | |
| 0.1.42 | ^2.5.17 | MIT | |
| 0.1.41 | ^2.5.17 | MIT | |
| 0.1.40 | ^2.5.17 | MIT | |
| 0.1.39 | ^2.5.17 | MIT | |
| 0.1.38 | ^2.5.17 | MIT | |
| 0.1.37 | ^2.5.17 | MIT | |
| 0.1.36 | ^2.5.17 | MIT | |
| 0.1.35 | ^2.5.17 | MIT | |
| 0.1.34 | ^2.5.17 | MIT | |
| 0.1.33 | ^2.5.17 | MIT | |
| 0.1.32 | ^2.5.17 | MIT | |
| 0.1.31 | ^2.5.17 | MIT | |
| 0.1.30 | ^2.5.17 | MIT | |
| 0.1.29 | ^2.5.17 | MIT | |
| 0.1.28 | ^2.5.17 | MIT | |
| 0.1.27 | ^2.5.17 | MIT | |
| 0.1.26 | ^2.5.17 | MIT | |
| 0.1.25 | ^2.5.17 | MIT |
Showing the latest 30 of 31. See every release on npm