Skip to content
This repository has been archived by the owner on Dec 25, 2017. It is now read-only.

Dynamic setting field, how to set up validator #46

Closed
lynzz opened this issue Aug 14, 2015 · 8 comments
Closed

Dynamic setting field, how to set up validator #46

lynzz opened this issue Aug 14, 2015 · 8 comments

Comments

@lynzz
Copy link

lynzz commented Aug 14, 2015

code:

http://jsfiddle.net/lynzz/8zx3cnh6/

Business scene , think through the following settings, create a form with validation:

var fileds = [{
    label: '标题',
    name: 'title',
    value: '我就是我',
    validate:'required',
    placeholder: '请填写标题'
}, {
    label: '描述',
    name: 'description',
    value: '我就是我,是颜色不一样的烟火',
    validate:'required',
    placeholder: '请填写描述'
}];

Encountered do not know how to set v-model and validate issues.

PS: forgive my poor English

@lynzz lynzz changed the title 动态设置 field 时,如何设置 validator Dynamic setting field, how to set up validator Aug 14, 2015
@kazupon
Copy link
Owner

kazupon commented Aug 14, 2015

Hi @lynzz !!

Thank you for your reporting.

If anything, this issue is a topic of vuejs/discussion.

Maybe, you will probably helpful the following v-model setup issues.

But v-validator cannot support dynamic validator setup.

In Currently, you need to implement validation with the $compile or element directive.

I think that will support the v2.0 later.

@kazupon kazupon mentioned this issue Aug 14, 2015
14 tasks
@lynzz
Copy link
Author

lynzz commented Aug 15, 2015

Thanks! 😄

@lynzz lynzz closed this as completed Aug 15, 2015
@amanpatel
Copy link

@kazupon So are dynamic directives supported in Vue 1.x ?

I'd love to use vue-validator, but if I can't apply or register directives programmatically within a component, it wouldn't fit my needs.

@revati
Copy link

revati commented Jan 10, 2016

Are there any updates on this?

v-validate:{{ id }}="{{ rules }}"

// throws error
Uncaught InvalidCharacterError: Failed to execute 'setAttribute' on 'Element': '}}' is not a valid attribute name.

@kazupon kazupon added the 2.0 label Jan 10, 2016
@kazupon
Copy link
Owner

kazupon commented Jan 11, 2016

Sorry, In current version (2.0-alpha.9), We don't support the dynamic validator (dynamic component).

I'll plan to support.
please wait. 😸

@kazupon kazupon reopened this Jan 11, 2016
@lazabogdan
Copy link

@lynzz @kazupon How about this? http://jsfiddle.net/6f9g2a5p/4/

Probably not the ideal way, but I can't think of another workaround.

Let me know what you think.

@kazupon
Copy link
Owner

kazupon commented Jan 13, 2016

Please see #131

@lazabogdan
Copy link

@kazupon thanks! Looking good. I can finally get rid of those many validator instances and use fields.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants