nainarazz / comments

repo to hold comments for blog posts using utterances
1 stars 0 forks source link

create-form-from-json-schema #6

Open utterances-bot opened 8 months ago

utterances-bot commented 8 months ago

How to create a form from JSON schema using react-hook-form

Create dynamic forms from json data using react-hook-form library

https://nainacodes.com/blog/create-form-from-json-schema?utterances=5ea8b155fc4865249b4f1df02eaPvxVr2gYL4a3gqeOnRyMVk2CQ8QutHIJfbw2qVOT9j%2BrP%2B%2B%2FC2JvZyLQw5kaEDGLrmUHD2nGSzM5gtuECEzATH7%2B2ZUqU21Ukr%2FIsKSggBdRYcSW%2FKVOWtdA%3D

nnti3n commented 8 months ago

Very helpful

alex4brandung commented 5 months ago

first off, thanks... this helped me a lot to understand the concept! But I want to add this is no json you are using, its plain js. The fields object in data.ts is no json. A proper json object would introduce a problem here, because you cannot store functions in json as you do for your validations. The only way how to solve this would lead to have a mapping for all your validations and just pass the mapping name in your json?! Do you have another idea?

nainarazz commented 5 months ago

Hi @alex4brandung , yes you are right. Having the validation functions in the object will not be valid json (if we put it in a json file) Can't think of other ideas for now :), but I think mapping the validations as you have said might work.