'vuelidate vues js between rule not working exactly
I have to validate form with vue js before sening data, so I use vuelidate package,
I have a quantity filed that it has min and max value, I used betwwenrule from vuelidate like this :
validations : {
quantity: {
required,
between : between(1, this.quantityMAx)
},
}
and `quantityMax is a computed attribute :
quantityMax(){
if(this.item){
//console.log(parseFloat(this.item.qte_stock) - parseFloat(this.item.qte_stock_min))
return parseFloat(this.item.qte_stock) - parseFloat(this.item.qte_stock_min)
}
else return 1
},
and I got the following error :
Uncaught TypeError: undefined has no properties
./node_modules/babel-loader/lib/index.js??clonedRuleSet-5[0].rules[0].use[0]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./resources/assets/js/views/damage/Create.vue?vue&type=script&lang=js& Create.vue:288
....
But I used this validation in a componenet and it's working, I d'ont know what is the error !
I imort rules like this :
const {
required,
minValue,
between,
maxLength,
maxValue,
}
= require('vuelidate/lib/validators')
and just between that it has the issue
Solution 1:[1]
I fix it by using
validations () {
return { ...}
}
and not validions : { ....}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | MAHA OUEGHLANI |
