Vee-validate: Use of validateAll(scope) breaks required rule on list of select inputs

Created on 28 Oct 2017  路  5Comments  路  Source: logaretm/vee-validate

Versions:

  • VueJs: 2.5.2
  • Vee-Validate: RC19 and master branch as of time of posting.

Description:

I have a dynamic list of select inputs with the required rule on them. These select inputs use a certain scope. Within that scope, I also have a custom component that is not bound using v-model since it renders an array, so after the data for that component changes I just call validateAll(scope) on $nextTick because otherwise the initial validation for that custom component doesn't work. This works fine, but strangely enough when using validateAll(scope) the required rule on the list of select inputs breaks. This puts me in the awkward position that whether I add or remove validateAll, some validation is always broken. I may refactor all this code in the future, but in the meantime I don't think calling validateAll(scope) should break anything.

Steps To Reproduce:

https://jsfiddle.net/kt2r8r60/5/

馃悰 bug

All 5 comments

You are correct, calling validateAll shouldn't break or produce different results than the initial validation, I will take a look and report back. Probably the value resolution has issues with select inputs.

Thanks! :)

I found the problem, for starters it only occurs with Vue 2.4.3 and above, I think because of this change https://github.com/vuejs/vue/issues/6193

This is similar to #804 but not easily as fixable, because when you don't call validateAll the initial value is retrieved by the vnode which only happens initially. When you call validateAll the predefined getters are now the source of the value which for select elements aren't ready yet and so it receives an empty value.

Fixing it would require a different way of retrieving v-model bound values, preferably via the vnode data itself since it is isolated from all DOM cycles and the pain that comes with tracking them.

This has been fixed finally in the v3 branch, as the directive has been re-written.

Thanks @logaretm!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yyyuuu777 picture yyyuuu777  路  3Comments

schel4ok picture schel4ok  路  3Comments

YamenSharaf picture YamenSharaf  路  3Comments

MeltedFreddo picture MeltedFreddo  路  3Comments

HunterJS-bit picture HunterJS-bit  路  3Comments