vue-generators / vue-form-generator

:clipboard: A schema-based form generator component for Vue.js
MIT License
2.99k stars 531 forks source link

Validating multiple VFG's at the same time #328

Closed DelfsEngineering closed 6 years ago

DelfsEngineering commented 6 years ago

I have a use case where I have a Vue-Form-Wizard page with several VFG's some are in accordions, others in tab widgets. All custom components with VFG. I want to validate all the components at the same time on a given tab.

The schema for each page is dynamic and all comes from a DB call so I can not hardcode the validations.

I am thinking of ways to do this. One way I am thinking is each VFG sub-component would register itself with its parent. Parents would register then validation hooks with their parents where applicable.

This would allow validation to occur from any point in the tree downward. Meaning, for a use case like a wizard, that particular step could be fully validated before proceeding to the next step.

The challenges I'd like to get thoughts on are what would the best topology be for this.

An event bus would not have the hierarchy that is needed to validate just a tab or step on a wizard.

A flat array of references could work, where the parent has a larger array of all the child refs. Then when a validation is needed at any level each ref in the array would be called to validate and when done continues.

@icebob and @lionel-bijaoui What are your thoughts on this? Have I made this challenge clear enough?

lionel-bijaoui commented 6 years ago

Your problem is too specific. Good luck with your project !