kazupon / vue-validator

:white_check_mark: Validator component for Vue.js
MIT License
2.19k stars 431 forks source link

unregister looks for non-existent field #336

Closed heygambo closed 7 years ago

heygambo commented 8 years ago

vue & vue-validator version

2.0.3, 3.0.0-alpha.1

Problem

There is a callback being called when I destroy a the Vue component. That leads the validator's unregister function to be called.

It always leads to an error that I cannot make any sense of so far.

It iterates two times. The first time is correct, but this._validityWatchers changes in the second run so that the watcher cannot be found.

screenshot 2016-10-29 19 34 34

Code

That's the template:

<template>
  <validation name="validation">
    <form novalidate @submit.prevent="submit">
      <validity field="complaint" group="dispute" :validators="{ required: true, minlength: 4 }">
        <input @input="handleValidate" id="complaint" type="text">
      </validity>
      <validity field="body" group="dispute" :validators="{ required: true, minlength: 4 }">
        <textarea @input="handleValidate" id="body"></textarea>
      </validity>
    </form>
  </validation>
</template>

Screenshots

vue-validator-unregister-1

vue-validator-unregister-2

kazupon commented 8 years ago

Thank you for your feedback! I'll try to fix next release.

woshi82 commented 8 years ago

I have meet this problem too , ……