Vuelidate: Is it possible to use a variable for validation?

Created on 30 Jan 2017  路  4Comments  路  Source: vuelidate/vuelidate

Can I use a variable to validate? See example below:

data: function () {
    return {
        variable: 10
    }
},
validations: {

    form: {
        example: {
            between: between(this.variable, 400)
        }
    }
},

Most helpful comment

Yes, it's possible. You just have to enclose it into another function.

example: {
    between (value) {
        return between(this.variable, 400)(value)
    }
}

All 4 comments

Yes, it's possible. You just have to enclose it into another function.

example: {
    between (value) {
        return between(this.variable, 400)(value)
    }
}

Not working!

@Frizi what is value in your example? Why this is not working?

maxLength () {
        return maxLength(this.countProp)
      }

@ChrisRobston you can do that like this

validations () {
    return {
        textfieldValue: {
            required,
            maxLength: maxLength(this.countProp)
        }
    }
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

daverogers picture daverogers  路  3Comments

hasib32 picture hasib32  路  3Comments

jonjrodriguez picture jonjrodriguez  路  4Comments

mrcha90 picture mrcha90  路  3Comments

araujoyuri picture araujoyuri  路  3Comments