Vee-validate: v-validate can be dynamic?

Created on 1 Feb 2018  ยท  1Comment  ยท  Source: logaretm/vee-validate

I try to v-bind the v-validate attr.

<input :v-validate="'validateStr'" name="email" v-model="model" @input="onInput">

computed: {
    validateStr() {
        return "required|email";
    }
},

but it's not working.

https://codesandbox.io/s/mmzwowomlx

โ” question

Most helpful comment

Directives shouldn't use the colon for binding, the expression itself is bound automatically:

v-validate=" 'required' "

notice the extra single quotes (I added spaces for clarity), that is because we want it to be bound to a static string value.

You can bind it to an expression by passing it without the single quotes:

https://jsfiddle.net/eyf8b06q/9/

or bind it to a computed property or data property.

>All comments

Directives shouldn't use the colon for binding, the expression itself is bound automatically:

v-validate=" 'required' "

notice the extra single quotes (I added spaces for clarity), that is because we want it to be bound to a static string value.

You can bind it to an expression by passing it without the single quotes:

https://jsfiddle.net/eyf8b06q/9/

or bind it to a computed property or data property.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

triffer picture triffer  ยท  3Comments

YamenSharaf picture YamenSharaf  ยท  3Comments

Hoagiex picture Hoagiex  ยท  3Comments

kidox picture kidox  ยท  3Comments

Youdaman picture Youdaman  ยท  3Comments