question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: use .apply() on v-form validation rule invocations so the Vue instance can be referenced

See original GitHub issue

I’m new to Vuetify, but unless I’m missing something, it doesn’t appear that I can reference the Vue instance from a validation rule function. I’d like to request a feature where v-form calls validation rules with this set to the Vue instance - it is currently the window object.

  • What will it allow you to do that you can’t do today?

This will enable you to write validation rules where validation of one field depends on the value of another (for instance, “password” and “confirm password”). Also, in my case I like to suppress all errors until the form has been submitted once. Submission state is tracked on the Vue instance.

  • How will it make current work-arounds straightforward?

To my knowledge there is no workaround at the moment.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
lcheronecommented, Jun 1, 2018

This way wont work:

data: () => ({
  someRule: [
    v => !!v || 'Something is required',
    v => (v && this.someValidator(v)) || 'Something invalid',
  ]
}),
methods: {
  someValidator(value) {
    // validate
  }
}

But this will:

data: function () {
  return {
    someRule: [
      v => !!v || 'Something is required',
      v => (v && this.someValidator(v)) || 'Something invalid',
    ]
  }
},
methods: {
  someValidator(value) {
    // validate
  }
}

Had me stumped for abit… I prefer data: () => ({})

0reactions
KaelWDcommented, Oct 29, 2017

With Vue 2.5, you can use a lambda for data again as it now gets passed the vm instance as an argument.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to implement form validation with Vuetify in a Vue.js app
In this blog post, we'll learn how to build a registration form and validate it using Veutify. First, let start by creating a...
Read more >
How To Validate Forms in Vue.js
At the end of this tutorial, you will have a registration form that uses VeeValidate to validate the input fields. Prerequisites. This tutorial ......
Read more >
Simple Vue.js Form Validation with Vuelidate
Form validation with Vue.js can be surprisingly tricky. In this article, we see how Vuelidate can be used to make things easier.
Read more >
SPIR-V Specification - Khronos Registry
Invocation : A single execution of an entry point in a SPIR-V module, operating only on the amount of data explicitly exposed by...
Read more >
Form component
Forms. When it comes to form validation, Vuetify has a multitude of integrations and baked in functionality. Want to use a 3rd party ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found