2

I'm using Vue.js with Vue Validator and I'm trying to implement some dynamic validation. By this I mean the set of rules for a particular form field may change as a result of the rule being bound to a dynamic or computed variable. This is what I mean:

<input v-validate:field="someDynamicRule">

and in my Vue component the value of someDynamicRule can change:

//...
computed: {
  someDynamicRule () {
    return this.someBool ? ['required'] : []
  }
}
//...

However, this doesn't work; the validation rule is stuck with what it was when the component is first loaded. Here is a fiddle demonstrating this behaviour:

http://jsbin.com/furepirowi/edit?html,js,output

Is there a way to have the validator react to changes to the rules set on the fields?

harryg
  • 23,311
  • 45
  • 125
  • 198

0 Answers0