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.

data-scope prevents initial validation

See original GitHub issue

I have created a form with one text input, which has two validations, please see below.

Example 1 - without data-scope

form.col-xs-6
  input-group
    label.col-form-label.col-xs-4 email
    .col-xs-8
      input.form-control(v-model="email", v-validate="email", data-rules="required|email")
    p.text-danger(v-if="errors.has('email')") {{ errors.first('email') }}
hr
pre {{ errors | json }}

Without data-scope the above validations run immediately when the page is loaded and the error message is displayed accordingly. Also, I dump the errors object below the form to see what errors are set, which looks like this:

{
  "errors": [
    {
      "field": "email",
      "msg": "The email is required."
    },
    {
      "field": "email",
      "msg": "The email must be a valid email."
    }
  ]
}

Example 2 - with data-scope

With data-scope set to form1, as shown below, the validation error only shows once I enter some text into the input control.

form.col-xs-6(data-scope="form1")
  input-group
    label.col-form-label.col-xs-4 email
    .col-xs-8
      input.form-control(v-model="email", v-validate="email", data-rules="required|email")
    p.text-danger(v-if="errors.has('email','form1')") {{ errors.first('email','form1') }}
hr
pre {{ errors | json }}

Please note that the dumped errors object is exactly the same initially as without data-scope. Only after you enter at least one character in the input control do you get a new key in the dumped errors object, this time with a "scope": "form1".

{
  "errors": [
    {
      "field": "email",
      "msg": "The email is required."
    },
    {
      "field": "email",
      "msg": "The email must be a valid email."
    },
    {
      "field": "email",
      "msg": "The email must be a valid email.",
      "scope": "form1"
    }
  ]
}

Also, the examples in the documentation exhibit this same problem, please see http://vee-validate.logaretm.com/examples#scope-example.

Thanks for your help.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
logaretmcommented, Mar 22, 2017

@philipzaengle a lot has been changed since then, actually there is hardly any initial validation occurring, and .inital modifier doesn’t do anything atm, I’m considering either leaving the default as no initial validation and .initial forces validating on bind, so I’m looking to introduce a breaking change by reversing the effect of .initial

1reaction
pbastowskicommented, Nov 30, 2016

@logaretm I have created a codepen with examples that illustrate the problem http://codepen.io/pbastowski/pen/bBovBO?editors=1000

There are three sections in the example. The first two use data-vv-scope and the last one does not. The last one works as expected.

Read more comments on GitHub >

github_iconTop Results From Across the Web

checkValidity - HCL Leap 9
checkValidity(flags, dataScope, UIScope, UIReference) ... The checkValidity function stops at the first validation error that it finds, unless specified ...
Read more >
Advanced Quality Planning (APQP): planning tool - DataScope
This process will ensure that the new products meet the requirements established in the original design. Design verification can include ...
Read more >
Service Manual - Mindray North America
This manual provides detailed information about the assembling, disassembling, testing, and troubleshooting of the equipment to support ...
Read more >
An Exploratory Study on the Validation of THUNDERS ... - MDPI
The post-process phase aims to verify the resolution of the collaborative activity problem, where it is initially verified that the success criteria were...
Read more >
Adding Data Pattern Definitions and Validation Method to ...
This implements an additional method of data validation on top of advanced pattern matching to prevent false positives. The Luhn method is commonly...
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