Search code examples
vue.jsvuejs2vuelidate

Vuelidate checking for true/false


I have a custom checkbox

<checkbox v-model="form.terms_accepted" />

The true/false value toggles fine

{
"first_name": "", 
"last_name": "", "username": "", 
"email": "", "terms_accepted": true 
}

How do I validate for a true value?

at the moment I my validation rule is.

terms_accepted: {
         required
},

Solution

  • You can use a simple function:

    terms_accepted: {
      checked: value => value === true
    }