Simple Vue 3 validator is a lightweight yet flexible plugin for Vue.js 3.0 that allows you to validate input fields, and display errors. It watches changes of your model data, validates them, and informs you with the validation result.
It supports the following features:
- Fully customized validation rules.
- Cross field validation.
- Async/ajax validation (with supports of loading indicator, result caching, debounced user input).
- Validating custom component.
- Dynamic form / multiple validation instances.
Package is installable via npm.
npm install --save simple-vue3-validator
You can also install it via bower.
bower install --save simple-vue3-validator
- Bower installation is untested as of 2021/05/30
- For bower package, please use /dist/plugin.js
import { createApp } from 'vue'
import App from './App.vue'
import SimpleVueValidator from 'simple-vue3-validator'
const app = createApp(App)
.use(SimpleVueValidator)
Define the validators
object in your vue / component instance:
validators: {
email (value) {
return Validator.value(value).required().email();
}
}
In the template HTML use the validation
object injected by the library to display validation status / results.
<div class="message">{{ validation.firstError('email') }}</div>
Full documentation coming soon ⌚