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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'rules' of undefined #1192

Closed
lucien144 opened this issue Mar 2, 2018 · 2 comments
Closed

TypeError: Cannot read property 'rules' of undefined #1192

lucien144 opened this issue Mar 2, 2018 · 2 comments

Comments

@lucien144
Copy link

lucien144 commented Mar 2, 2018

Versions:

  • VueJs: 2.5.2
  • Vee-Validate: 2.0.4

Description:

馃憢 Hello! Thanks for the awesome plugin!
I'm coming with an issue... I'm passing validation rules to a custom component that's basically just a wrapper for input field. I'm passing those rules using props. The app produces 2 errors after start however the validation in that field seems to be working... Am I missing anything?

http://144.wtf/9rhznM

Steps To Reproduce:

Parent:

<template>
	<form>
		<base-input type="email" name="email" :validate="'required|email'">Your email?</base-input>
	</form>
</template>

Component - BaseInput.vue

<template>
	<div :class="['form-input']" :id="[`form-input--${name}`]">
		<input :type="type" :name="name" :id="name" :required="required ? required : null" v-validate="validate" />
		<label :for="name"><slot/></label>
        <span v-show="errors.has(name)" class="help is-danger">{{ errors.first(name) }}</span>
	</div>
</template>

<script>
export default {
	props: ['type', 'name', 'required', 'validate'],
};
</script>

Thanks!

@logaretm
Copy link
Owner

logaretm commented Mar 2, 2018

I have tried to replicate your issue here:

https://codesandbox.io/s/7l6y0yllx

seems to work fine, however I patched the resolveRules method with additional checks to prevent this issue from happening.

@lucien144
Copy link
Author

Hi @logaretm,
thanks for this! It helped, all is good now. Really appreciate your hard work on this!

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

2 participants