ragnarlotus/vue-daval

@blur problem with $validate()

Opened this issue · 1 comments

patie commented

hi,

<div :class="{ 'form__group': true, 'error': $vd.form.firstname.$hasError }">
                                    <div class="h-flex">
                                        <label class="form__label" for="forename">Jméno<span class="h-red"> *</span></label>
                                    </div>

                                    <input @blur="$vd.form.firstname.$validate()" type="text" v-model="form.firstname" name="forename" autocomplete="off" class="form__control " id="forename" maxlength="50">
                                    <span class="error__message" v-if="$vd.form.firstname.$hasError === true">Vyplňte prosím křestní jméno</span>
                                </div>

    data() {
            return {
                form: {
                    firstname: '',
                    email: ''
                }
            }
        },
        vdRules: {
            form: {
                email: {required: true, type: 'email'},
                firstname: {required: true, minlen: 2}
            },
        },
        methods: {
            onBlur() {
                this.$vd.form.firstname.$validate();
            }
        },

when i use @blur="$vd.form.firstname.$validate()" i get error message TypeError: err is undefined, but when i do @blur="onBlur()" it working ok withour error. Any idea please?

Really sorry for the super late answer.... I didn't notice about it.

Initially it has no sense at all, but I will investigate it.

Thanks for reporting!