Live data from Hacker News

Show HN: Generate React forms from JSON form schemas

github.com

1–10 of 28 posts

Re: Show HN: Generate React forms from JSON form schemas

#4
I would strongly recommend that anyone looking into something like this first look at JSON Schema[1], which is a pretty widely adopted standard. We're doing server and client validation with one set of rules, and there are lots of libraries that will clean up your data given a schema.

[1] http://json-schema.org/examples.html

Re: Show HN: Generate React forms from JSON form schemas

#6

See also tcomb-form [1] with it's tcomb-json-schema plugin [2]. We're currently using react-forms with a custom json-schema to react-forms schema conversion. [1] https://github.com/gcanti/tcomb-form [2] https://github.com/gcanti/tcomb-json-schema

Also https://github.com/christianalfoni/formsy-react

Re: Show HN: Generate React forms from JSON form schemas

#7

I would strongly recommend that anyone looking into something like this first look at JSON Schema[1], which is a pretty widely adopted standard. We're doing server and client validation with one set of rules, and there are lots of libraries that will clean up your data given a schema. [1] http://json-schema.org/examples.html

Yep, it's really too bad all of these form builders out there invent their own DSL instead of using the JSON Schema standard.

Re: Show HN: Generate React forms from JSON form schemas

#8

I would strongly recommend that anyone looking into something like this first look at JSON Schema[1], which is a pretty widely adopted standard. We're doing server and client validation with one set of rules, and there are lots of libraries that will clean up your data given a schema. [1] http://json-schema.org/examples.html

I second this.

On our backend we have a main service in Python and a few micro-services in Node. All of the JSON data flying between these services has JSON Schema definitions.

We've built some express.js and wsgi middleware so that for a given route you can specify "Requests to this endpoint should follow schema {} responses from this endpoint should follow schema {}." Our middleware then validates all requests and responses against these schema. This works really well for us.

Re: Show HN: Generate React forms from JSON form schemas

#10

I would strongly recommend that anyone looking into something like this first look at JSON Schema[1], which is a pretty widely adopted standard. We're doing server and client validation with one set of rules, and there are lots of libraries that will clean up your data given a schema. [1] http://json-schema.org/examples.html

I have some experience in this. Problem is, JSON Schema doesn't give you some attributes like order of properties for building the form.

What makes sense is extending JSON Schema with optional properties that fill in things JSON Schema doesn't provide yet make it work with nothing but a JSON Schema.

json-editor[1] does a very good job in this regard.

Libraries like these are repeating what people have done already previously (classic JS framework DRY problem). They will need to solve a lot of corner cases to mature. Recursion, oneOf and some other JSON Schema properties are pretty hard to implement.

[1] https://github.com/jdorn/json-editor

Post reply on HN