vuelidate / vuelidate

Simple, lightweight model-based validation for Vue.js
https://vuelidate-next.netlify.app/
MIT License
6.86k stars 496 forks source link

Array $each validate show invalid when load page #1207

Open LeonGit-available opened 11 months ago

LeonGit-available commented 11 months ago

Hello, I facing $each validate problem.

Issue when page loaded $each.$response.$errors always showing errors.

Expected behavior $each.$response.$errors not show errors when do nothing input.

More inform but if now using $each like first code provide. v$.productOption[x.model].$errors value empty when page load only after I key and unkey some thing the error show.

Thanks.

          <AppFormField
            v-else
            v-model="v$.productOption[x.model].$model"
            :title="$t(`label.${x.title}`)"
            :isRequired="x.isRequired"
            :validators="x.validators"
            :validationValue="v$.productOption[x.model].$errors"
          >
          </AppFormField>
                <AppFormField
                  v-model="
                    v$.productOption.$model.translations[languages][x.model]
                  "
                  class="mb-3"
                  :title="$t(`label.${x.title}`)"
                  :isRequired="x.isRequired"
                  :validators="x.validators"
                  :validationValue="
                    v$.productOption.translations.$each.$response.$errors[
                      languages
                    ][x.model]
                  "
                  prepend
                  notitle
                >
                  <template v-slot:prepend>
                    {{ language.abbreviation }}
                  </template>
                </AppFormField>
renatodeleao commented 11 months ago

Related: https://github.com/vuelidate/vuelidate/issues/1072 TL;DR: I had to stop using arrays and $each with vuelidate for collections and workaround by relying on nested objects.

Good luck!