simple-vue-validator
simple-vue-validator copied to clipboard
Validator is not defined
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 =/
You need to also import {Validator} from 'simple-vue-validator'
in the file that uses it.
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
That might be because you don't have any validators
defined.
import {Validator} from 'simple-vue-validator'
in each component? why not like router? this.$validator
Hello, Did anyone got through with this issue? Please share answer. Thanks.
Same Here . Works in one component only. get the same error when used in another component
validators: {
'form.email': function (value) {
if( value != undefined ) {
return Validator.value(value).required().email();
}
}
},