Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field is always initially valid #1829

Closed
ansbar opened this issue Jan 27, 2019 · 3 comments
Closed

Field is always initially valid #1829

ansbar opened this issue Jan 27, 2019 · 3 comments

Comments

@ansbar
Copy link

ansbar commented Jan 27, 2019

Lets try again.

Check this sandbox out: https://codesandbox.io/s/62v6q0mw4r

The first field is stand alone with required and gets valid: false initially.

The second value is inside a validation-provider with required and it gets valid: true initially.

Is this supposed to happend or a bug?

<template>
  <div class="hello">
    <h1>{{ msg }}</h1>

    <input
      type="text"
      name="field2"
      v-validate="'required|alpha'"
      v-model="field2"
    /><br />
    Valid: {{ fields.field2.valid }} <br />
    {{ fields }} <br /><br />

    <template>
      <ValidationProvider rules="required|alpha">
        <div slot-scope="{ classes, errors }">
          <input type="text" name="field" v-model="field" /><br />
          Valid: {{ classes.valid }} <br />
          {{ errors[0] }}<br />
          {{ classes }}
        </div>
      </ValidationProvider>
    </template>
  </div>
</template>

<script>
import { ValidationProvider } from "vee-validate";

export default {
  name: "HelloWorld",
  components: {
    ValidationProvider
  },
  data() {
    return {
      field: "",
      field2: "",
      msg: "Welcome to Your Vue.js App"
    };
  }
};
</script>

Is it supposed to work this way?

@ansbar
Copy link
Author

ansbar commented Jan 28, 2019

@logaretm Please have a look again. Ive added a sandbox.

@ansbar
Copy link
Author

ansbar commented Jan 28, 2019

"Triggering validation on any of the providers is simple, but it is opt-in. Meaning you need to explicity call the validation on the provider instance. Using refs and the public method validate makes it straight forward." Thats what I missed?

@ansbar
Copy link
Author

ansbar commented Jan 28, 2019

The validationprovider input classes actually says "required": false"..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant