fastest-validator icon indicating copy to clipboard operation
fastest-validator copied to clipboard

Form generator from FV schema

Open icebob opened this issue 5 years ago • 4 comments

Similar to #186, I would like to create a frontend module which can generate HTML forms based on the FV schema because it contains every information about the type of fields, valid values, default values, validators...etc. And before submitting I can use FV to validate the values.

But to create it, I need a method which resolves (shorthand formats) the FV schema to a full JSON. @erfanium I think you should need something similar for fv-document-generator. Did you start to work on it?

icebob avatar Oct 10 '20 09:10 icebob

@icebob https://github.com/icebob/fastest-validator/blob/master/lib/validator.js#L331 Isn't this what you are looking for?

erfanium avatar Oct 10 '20 10:10 erfanium

Yeah, something similar, but would be good a function which traverse the whole schema and convert all of them. And I need another one which creates an object with the default values.

icebob avatar Oct 11 '20 07:10 icebob

@icebob the first one I am working on in a separate repository. At the moment I stopped at solving problems with the properties $$type and $$root. I still need to improve the logic when parsing the schema recursively.

intech avatar Oct 11 '20 11:10 intech

With default values, the fields are easy to implement if you add default values ​​directly to the rules.

intech avatar Oct 11 '20 11:10 intech