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.
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