Is there any way I can access the component's scope from inside a form validation method? (this.min, this.max)
I have some complex validations that depend on other component data. Is accessing data from inside the rules' methods the correct way to do this? If not, can someone please recommend a better way? Thanks!
<template>
<v-form ref="form" v-model="valid">
<v-text-field
v-model="age"
:rules="[myRules.age]"
label="Label"
required
>
</v-text-field>
<v-btn
color="primary"
:disabled="!valid"
@click="submit"
>
submit
</v-btn>
<v-btn
@click="clear"
>
clear
</v-btn>
</v-form>
</template>
<script>
data(){
return{
min: 21,
max: 65,
valid: true,
myRules: {
age: (value) => {
return this.min < value < this.max
}
}
}
},
methods:{
clear() {
this.$refs.form.reset()
}
}
</script>