simple-vue-validator icon indicating copy to clipboard operation
simple-vue-validator copied to clipboard

Validator is not defined

Open mikevelez opened this issue 6 years ago • 7 comments

I'm using Vue2 I ran npm install --save simple-vue-validator

in my main.js file i have:

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import BootstrapVue from 'bootstrap-vue'
import SimpleVueValidation from 'simple-vue-validator';

Vue.use(SimpleVueValidation);
Vue.use(BootstrapVue);
Vue.config.productionTip = false;

import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')

In my component script section I added:

validators: {
    'form.email': function (value) {
        return Validator.value(value).required().email();
    }
 },

and I run this on my submit:

 this.$validate()
.then(function(success) {
    if (success) {
        alert('Validation succeeded!')
    }
});

This looks like a great library but it's not working for me =/

mikevelez avatar Oct 20 '18 07:10 mikevelez

You need to also import {Validator} from 'simple-vue-validator' in the file that uses it.

semisleep avatar Oct 26 '18 00:10 semisleep

I also get this, I tried importing Validator as mentioned above but no luck Property or method "validation" is not defined on the instance but referenced during render

johnsoncarneiro avatar Jan 17 '19 04:01 johnsoncarneiro

That might be because you don't have any validators defined.

semisleep avatar Feb 06 '19 14:02 semisleep

import {Validator} from 'simple-vue-validator'

in each component? why not like router? this.$validator

SlivaNilow avatar Feb 20 '19 18:02 SlivaNilow

Hello, Did anyone got through with this issue? Please share answer. Thanks.

Sookdeo avatar Jan 14 '20 20:01 Sookdeo

Same Here . Works in one component only. get the same error when used in another component

shahabgohar avatar Apr 17 '20 07:04 shahabgohar

validators: {
    'form.email': function (value) {
        if( value != undefined ) {
              return Validator.value(value).required().email();
        }
    }
 },

mhariscoder avatar Jan 17 '22 18:01 mhariscoder