question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vee Validate complains about errors not defined

See original GitHub issue

I’m trying to install Vee Validate into my Nuxt JS v2.6.3 application. I’m using Nuxt JS in universal mode, and have added a vee-validate.js plugin file in the plugins folder, the contents of this file are:

import Vue from 'vue';
import VeeValidate from 'vee-validate';

Vue.use(VeeValidate, { inject: false });

I have then included this in my nuxt.config.js file using the server mode for this file:

plugins: [
  ...
  { mode: 'server', src: '@/plugins/vee-validate' }
  ...
]

Then, in my page, but I have also tried a component file as well, I’ve got a simple input setup with validation:

pages/apply.vue

<div class="form-group mb-0" v-if="loaded">
  <label class="form-label" for="AppLoanPurposeOther">Please tell us the reason for your loan:</label>
  <input v-validate="'required'" v-bind:class="this.errors.has('data[ApplicationPayday][AppLoanPurposeOther]') ? 'is-invalid' : ''" name="data[ApplicationPayday][AppLoanPurposeOther]" id="AppLoanPurposeOther" class="form-control form-control-lg" type="text">
</div>

Unfortunately, with this setup I get the following console error:

Property or method "errors" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.

This is rather frustrating, as it is included in the project, I have Vee Validate version 2.2.7, and have tried switching the mode of the Vee Validate JS file, I’ve tried using: inject: true and inject: false, with little luck.

What am I missing?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
logaretmcommented, Aug 8, 2019

inject: false removes the error messages from Vue instances.

You need to inject the instance yourself like this:

export default {
  $_veeValidate: {
	validator: 'new'
  }
};

This is documented here

1reaction
jordanbostoncommented, Mar 16, 2020

@vincent-kean I ended up installing this component globally for my app and using a different name for the errors.

import VeeValidate from 'vee-validate'

Vue.use(VeeValidate, { errorBagName: 'vErrors' })

Then using that throughout my app worked without those errors.

:show="vErrors.first('password')">{{ vErrors.first('password')

Read more comments on GitHub >

github_iconTop Results From Across the Web

VeeValidate errors is not defined when importing into custom ...
I'm building a custom Vue JS plugin using the vue create CLI. I've imported my various packages, however, I'm getting an error when...
Read more >
Displaying Errors - VeeValidate
Typically you would want to display one error at a time for your fields, you can do this using errors.first('fieldName') method. ... VeeValidate...
Read more >
Error Messages - VeeValidate
Error Messages. VeeValidate comes with generic error messages, which can be overwritten or assign specific messages for specific fields.
Read more >
Flags | VeeValidate
vee -validate includes few flags that could help you improve your user experience, each field under validation has its own set of flags...
Read more >
Validation Provider - VeeValidate
<template> <ValidationProvider rules="required" v-slot="{ errors }"> <input v-model="value" ... rules, string | object, undefined, The validation rules.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found