Search code examples
vuelidate

Vuelidate "OR" validator example


OK - searched for quite a while all over and cannot find an example or using the OR validator from Vuelidate. The one mentioned in this github issue is not valid and the issue resolves without providing a valid OR example. The docs mention it exists but do not have any example that we could find. Anyone have or know of an valid example?


Solution

  • If you want a field that take multiple validation types, like signing in with a username or email address, you can do something like this

    data () {
      return {    {
       multiusername: '',
      }
    },
    validations: {
      multiusername: {
        required,
        mycustomval: or(email, alphaNum)
      }
    }