Gathering detailed insights and metrics for @vuelidate/core
Gathering detailed insights and metrics for @vuelidate/core
Gathering detailed insights and metrics for @vuelidate/core
Gathering detailed insights and metrics for @vuelidate/core
@markmeyer/vuelidate-core
Simple, lightweight model-based validation for Vue.js
@igonato/vuelidate-core
Simple, lightweight model-based validation for Vue.js
@vue-demi/vuelidate-core
Simple, lightweight model-based validation for Vue.js
@clearlyhope/vuelidate-core
Simple, lightweight model-based validation for Vue.js
Simple, lightweight model-based validation for Vue.js
npm install @vuelidate/core
Typescript
Module System
Node Version
NPM Version
@vuelidate/core@2.0.1
Updated on Mar 26, 2023
@vuelidate/core@2.0.0
Updated on Sep 25, 2022
@vuelidate/validators@2.0.0-alpha.31
Updated on Jul 23, 2022
@vuelidate/core@2.0.0-alpha.43
Updated on Jul 23, 2022
@vuelidate/core@2.0.0-alpha.41
Updated on May 01, 2022
@vuelidate/validators@2.0.0-alpha.29
Updated on May 01, 2022
JavaScript (64.94%)
Vue (12.52%)
Sass (10.92%)
Pug (9.6%)
SCSS (1.35%)
HTML (0.66%)
Total Downloads
30,813,133
Last Day
7,474
Last Week
295,422
Last Month
1,285,759
Last Year
13,018,733
MIT License
6,906 Stars
671 Commits
490 Forks
77 Watchers
6 Branches
84 Contributors
Updated on Jul 07, 2025
Minified
Minified + Gzipped
Latest Version
2.0.3
Package Id
@vuelidate/core@2.0.3
Unpacked Size
81.58 kB
Size
19.03 kB
File Count
8
NPM Version
8.19.2
Node Version
18.10.0
Published on
Jun 29, 2023
Cumulative downloads
Total Downloads
Last Day
-11%
7,474
Compared to previous day
Last Week
-18.4%
295,422
Compared to previous week
Last Month
9.6%
1,285,759
Compared to previous month
Last Year
36.5%
13,018,733
Compared to previous year
1
2
Simple, lightweight model-based validation for Vue.js 2.x & 3.0
Visit Vuelidate Docs for detailed instructions.
You can use Vuelidate just by itself, but we suggest you use it along @vuelidate/validators
, as it gives a nice collection of commonly used
validators.
Vuelidate supports both Vue 3.0 and Vue 2.x
1npm install @vuelidate/core @vuelidate/validators 2# or 3yarn add @vuelidate/core @vuelidate/validators
To use Vuelidate with the Options API, you just need to return an empty Vuelidate instance from setup
.
Your validation state lives in the data
and the rules are in validations
function.
1import { email, required } from '@vuelidate/validators' 2import { useVuelidate } from '@vuelidate/core' 3 4export default { 5 name: 'UsersPage', 6 data: () => ({ 7 form: { 8 name: '', 9 email: '' 10 } 11 }), 12 setup: () => ({ v$: useVuelidate() }), 13 validations () { 14 return { 15 form: { 16 name: { required }, 17 email: { required, email } 18 } 19 } 20 } 21}
To use Vuelidate with the Composition API, you need to provide it a state and set of validation rules, for that state.
The state can be a reactive
object or a collection of refs
.
1import { reactive } from 'vue' // or '@vue/composition-api' in Vue 2.x 2import { useVuelidate } from '@vuelidate/core' 3import { email, required } from '@vuelidate/validators' 4 5export default { 6 setup () { 7 const state = reactive({ 8 name: '', 9 emailAddress: '' 10 }) 11 const rules = { 12 name: { required }, 13 emailAddress: { required, email } 14 } 15 16 const v$ = useVuelidate(rules, state) 17 18 return { state, v$ } 19 } 20}
You can provide global configs to your Vuelidate instance using the third parameter of useVuelidate
or by using the validationsConfig
. These
config options are used to change some core Vuelidate functionality, like $autoDirty
, $lazy
, $scope
and more. Learn all about them
in Validation Configuration.
1<script> 2import { useVuelidate } from '@vuelidate/core' 3 4export default { 5 data () { 6 return { ...state } 7 }, 8 validations () { 9 return { ...validations } 10 }, 11 setup: () => ({ v$: useVuelidate() }), 12 validationConfig: { 13 $lazy: true, 14 } 15} 16</script>
1import { reactive } from 'vue' // or '@vue/composition-api' in Vue 2.x 2import { useVuelidate } from '@vuelidate/core' 3import { email, required } from '@vuelidate/validators' 4 5export default { 6 setup () { 7 const state = reactive({}) 8 const rules = {} 9 const v$ = useVuelidate(rules, state, { $lazy: true }) 10 11 return { state, v$ } 12 } 13}
v$
object1interface ValidationState { 2 $dirty: false, // validations will only run when $dirty is true 3 $touch: Function, // call to turn the $dirty state to true 4 $reset: Function, // call to turn the $dirty state to false 5 $errors: [], // contains all the current errors { $message, $params, $pending, $invalid } 6 $error: false, // true if validations have not passed 7 $invalid: false, // as above for compatibility reasons 8 // there are some other properties here, read the docs for more info 9}
Validation in Vuelidate 2 is by default on, meaning validators are called on initialisation, but an error is considered active, only after a field is dirty, so after $touch()
is called or by using $model
.
If you wish to make a validation lazy, meaning it only runs validations once it a field is dirty, you can pass a { $lazy: true }
property to
Vuelidate. This saves extra invocations for async validators as well as makes the initial validation setup a bit more performant.
1const v = useVuelidate(rules, state, { $lazy: true })
If you wish to reset a form's $dirty
state, you can do so by using the appropriately named $reset
method. For example when closing a create/edit
modal, you dont want the validation state to persist.
1 2<app-modal @closed="v$.$reset()"> 3<!-- some inputs --> 4</app-modal>
The validation state holds useful data, like the invalid state of each property validator, along with extra properties, like an error message or extra parameters.
Error messages come out of the box with the bundled validators in @vuelidate/validators
package. You can check how change those them over at
the Custom Validators page
The easiest way to display errors is to use the form's top level $errors
property. It is an array of validation objects, that you can iterate over.
1 2<p 3 v-for="(error, index) of $v.$errors" 4 :key="index" 5> 6<strong>{{ error.$validator }}</strong> 7<small> on property</small> 8<strong>{{ error.$property }}</strong> 9<small> says:</small> 10<strong>{{ error.$message }}</strong> 11</p>
You can also check for errors on each form property:
1<p 2 v-for="(error, index) of $v.name.$errors" 3 :key="index" 4> 5<!-- Same as above --> 6</p>
For more info, visit the Vuelidate Docs.
To test the package run
1# install dependencies 2yarn install 3 4# create bundles. 5yarn build 6 7# Create docs inside /docs package 8yarn dev 9 10# run unit tests for entire monorepo 11yarn test:unit 12 13# You can also run for same command per package
No vulnerabilities found.
Reason
security policy file detected
Details
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 13/28 approved changesets -- score normalized to 4
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
64 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More