kazupon / vue-validator

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

How can I insert the computed property in this case? #275

Closed vip30 closed 8 years ago

vip30 commented 8 years ago

Here is the fiddle https://jsfiddle.net/pn4pojjw/

Supposing I have a data that call validate <input v-validate="validate" :field="field1" />

{validate : { required: { rule: true, message: "Require It"} }

I would like to have a confirm password checking like this https://jsfiddle.net/kazupon/kdvdvdze/7/ I know that may need to use computed property, but how to insert the computed property in object?

Thanks!!

kazupon commented 8 years ago

You can wrap the computed property with custom validator. see the below example: https://jsfiddle.net/oqpmwdx1/1/

vip30 commented 8 years ago

But I am afraid that this settings will make the computed properties not reactive.

https://jsfiddle.net/kdvdvdze/9/

In your beginning example, (https://jsfiddle.net/kdvdvdze/8) the error message will show either the password field is changed or the confirm password field is changed.

But if we wrap the computed property with the validator, the validation will be triggered by confirm password field only Do you have any other idea about that? Thanks alot!