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.

Not working with nuxtjs

See original GitHub issue

Versions:

  • VueJs: #.#.# nuxtjs v0.10.7
  • Vee-Validate: 2.0.0-rc.5

Description:

Simple implementation with nuxtjs, following the example, not working! Not able to figure out the cause.

Steps To Reproduce:

Any sample, wiht validator added via npm/yarn… then registered using a plugin:

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

Vue.use(VeeValidate)

Now when I use it on the form on the page, errors is undefined and so is $validator.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

17reactions
SharadKumarcommented, Jun 6, 2017

Okay, this works!

~plugins/vee-validate.js

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

Vue.use(VeeValidate, {
  inject: true
})

then, nuxt.config.js

plugins: [
    {src: '~plugins/vee-validate.js', ssr: true}
  ]

then, in my page:

methods: {
    validateBeforeSubmit(e) {
      this.$validator.validateAll().then(x => {
        console.log(x)
      }).catch(e => {
        console.log(e)
      })
    }
}

and template:

   <div class="form-group" :class="{'has-danger': errors.has('name') }">
      <label for="name" class="sr-only">Name</label>
      <input type="text" name="name" class="form-control" placeholder="Full name" v-validate="'required'" autofocus>
      <span v-show="errors.has('name')" class="form-control-feedback">{{ errors.first('name') }}</span>
    </div>
    <div class="form-group" :class="{'has-danger': errors.has('email') }">
      <label for="email" class="sr-only">Email address</label>
      <input class="form-control" name="email" type="text" placeholder="Email" v-validate="'required|email'">
      <span v-show="errors.has('email')" class="form-control-feedback">{{ errors.first('email') }}</span>
    </div>
    <div class="form-group" :class="{'has-danger': errors.has('password') }">
      <label for="password" class="sr-only">Password</label>
      <input v-model="password" type="password" class="form-control" placeholder="Password" v-validate="'required'">
      <span v-show="errors.has('password')" class="form-control-feedback">{{ errors.first('password') }}</span>
    </div>
    <div class="form-group" :class="{'has-danger': errors.has('passwordConfirm') }">
      <label for="password" class="sr-only">Confirm Password</label>
      <input v-model="passwordConfirm" type="password" class="form-control" placeholder="Re-type password" v-validate="'required'">
      <span v-show="errors.has('passwordConfirm')" class="form-control-feedback">{{ errors.first('passwordConfirm') }}</span>
    </div>
    <div class="form-group">
      <button @click="validateBeforeSubmit" class="btn btn-primary">Submit Registration</button>
    </div>

Works fine. Please close the issue. Thanks for your help @logaretm 👍

13reactions
farhadniazcommented, Dec 12, 2018

@SharadKumar @logaretm @finalight @horan-geeker @blackpr you can use vue-joi-validation base on Joi , a good Vuejs plugin for validation purposes . no-conflict and SSR support and schema base

Features

Model based Decoupled from templates Schema based Built upon Joi Minimalistic Support for collection validations Support for nested models Contextified validators Easy to use with custom validators (e.g. Moment.js) Support for function composition Validates different data sources: Vuex getters, computed values, etc.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · nuxt/nuxt.js - GitHub
Nuxt 2 standalone build on azure devOps not working bug-report. #10790 opened on Nov 6 by nickelnext · Cannot read properties of undefined...
Read more >
Nuxtjs is not working in localhost:5000 but its working in 127.0 ...
I am developing an application using Nuxtjs . The application is opening when I try to access the URL 127.0.0.1 .
Read more >
Nuxtjs down today December, 2022? Nuxtjs.org not working ...
Nuxtjs.org website down Today December, 2022? Can't log in? Real-time problems and outages - here you'll see what is going on.
Read more >
Problems With Server-Side Plugins in Nuxt.js
In this article Josh Deltener explores one of the lesser-known issues with server-side plugins in Nuxt. Josh Deltener. Nuxt 3. Mastering Nuxt 3...
Read more >
Creating Server-side Rendered Vue.js Apps Using Nuxt.js
Open your browser to localhost:3000 and your project should be running. Not much different from creating a Vue Webpack project. However, when we...
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