Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic validation #135

Open
nomadinteractif opened this issue Dec 16, 2019 · 1 comment
Open

Dynamic validation #135

nomadinteractif opened this issue Dec 16, 2019 · 1 comment

Comments

@nomadinteractif
Copy link

No description provided.

@nomadinteractif
Copy link
Author

nomadinteractif commented Dec 16, 2019

Sorry for the multiple edits, I hit submit before I were done and my use case was a little off! Here is the real use case.

I use vue-mc has a form generator which contains form, fieldset and field has models.
export class FormItemModel extends BaseModel{ defaults() { return {...super.defaults(),...{ label : null, text : null, name : null, options : null, placeholder : null, type : null, value : null, required : null, /* */ isActive : true, events : null, /* field|fieldset */ componentType : 'field', /*is case of fieldset*/ formItemCollection :null, }} } ...
Is it possible to set the validation on specific models?
I didn't tried, but probably overwriting the complete validation function for each required model will do the trick, but it's not that clean rewriting the whole function to set a single attribute validation. Perhaps, something more like
setAttributeValidation(attributeName,fn) / removeAttributeValidation(attributeName)

This way, we could also update the validation on the fly, because currently the validation method is memoized (only run once).

As an example for a contest, I have a FormItemModel «age» and another FormItemModel «parent name» that are related. If participant age < 18, parent field is required.

Thank you

@nomadinteractif nomadinteractif changed the title Dynamic validatiobn Dynamic validation Dec 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant