VeeValidate doesn't trigger manual validation with errors.add


#1

Hi,

I’ve a encapsulated text input in a component like this (every info come from props). I think that the last two lines are important for my issue.

  input.text(
    :class='{ "error": errors.has(fieldId), "confirmed": false }'
    autocomplete='off'
    :type='isPassword ? "password" : "text"'
    :name='name'
    v-validate='validate'
    :data-vv-validate-on='onvalidate'
    :ref='elRef'
    :data-vv-as='fieldAlias'
    @input='$emit("input", $event.target.value)'
    @change='$emit("change", $event.target.value)'
  )

I’ve a parent form which contains multiple input like that. So I use it like:

                custom-input-text(
                  :label='$t("forms.fields.confirmPassword")'
                  scope='form-signup'
                  name='confirmPassword'
                  validate='required'
                  onvalidate='change'
                  :isPassword='true'
                  :fieldAlias='$t("forms.fields.password")'
                  @input='v => confirmPassword = v'
                  @change='handleConfirmPassword'
                )

Well. I had several problemas working with confirmed password so I decided to do it manually. So, as you see, @change I want to validate on blur, so I set the validator @change.

Finally I handle it with this onChange function

    handleConfirmPassword: function (v) {
      if (v !== this.signup.password) {
        console.debug('traza')
        this.errors.add({ // to do 
          field: 'confirmPassword',
          msg: this.$t('validations.messages.confirmed', [this.$t('forms.fields.password')]),
          scope: 'form-signup'
        })
      }
    },

I enter to the if, but anyone know why the error is added to the this.errorrs (error Bag ?) . I’ve done it before, so it could work

thanks


#2

but anyone know why the error is added to the this.errorrs

It is not added you mean ?

Each component has its own validator, do you use injection of parent validator ?
https://baianat.github.io/vee-validate/concepts/injections.html#injecting-parent-validator