
Show HN: Generate React forms from JSON form schemas - SteveVitali
https://github.com/SteveVitali/react-form-generator
======
o_____________o
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](http://json-
schema.org/examples.html)

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

~~~
zachrose
That sounds nice. At my shop we have all of that except the live validation,
and schemas almost inevitably fall behind.

What happens when the validation fails? Also, which end does the validation,
providers or consumers?

------
rathereasy
Whoa, this is pretty cool. People have been trying to do this for ages. If
they've been analyzing how people code, they have some valuable data to
develop from. I hope they make it!

I once made a programming language with a tree editor:
[https://youtu.be/w5-g0Hps6bA](https://youtu.be/w5-g0Hps6bA)

I had anyfix operators, so it was possible to write a program that read like
english. In fact, I once got someone to write the sqrt function (inspired by
the SICP) in Japanese:
[https://youtu.be/vwgvVpCRecE](https://youtu.be/vwgvVpCRecE)

I think this is really promising to introduce people to programming. How many
times have you heard someone say "programming is so frustrating! I always
misplace my semicolon." Also, not having syntax means that people can use DSLs
without having the pain to learn its syntax.

~~~
foota
I think you may have meant to post this on the tree based editor post?

------
n0us
I'm doing something similar with serializing django forms and sending them to
a react app that turns the json into a form. It's a really convenient way of
doing things.

~~~
jentulman
Really sorry, down voted you by mistake with a loose finger. App I use has
moved the vote buttons right where I scroll.

~~~
n0us
no prob I'm here for the discussion, not the karma

------
laurencerowe
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](https://github.com/gcanti/tcomb-
form) [2] [https://github.com/gcanti/tcomb-json-
schema](https://github.com/gcanti/tcomb-json-schema)

~~~
nutate
tcomb-form is the most elegant solution I've seen to this problem in React.
Really nice to use.

~~~
gcanti
Hi, author here. Thanks for your kind words :)

------
sudo_bang_bang
I just started learning React and it's great how libraries like these are
almost making the construction of front-end web components into a DSL via JSON
schemas.

------
tootie
Was working on a similar project that I never managed to finish. I think this
is a really useful tool. One thing missing is custom input widgets.

------
PretzelFisch
Maybe I am missing something but how are they dealing with dates?

~~~
Splendor
I would assume by using ISO 8601 dates which is the closest thing there is to
a standard date format in JSON.

~~~
bryanlarsen
i-JSON[1] (internet JSON a/k/a interoperable JSON) has a standard date format.
Not surprisingly, it's based on ISO 8601.

1: [https://tools.ietf.org/html/rfc7493](https://tools.ietf.org/html/rfc7493)

------
justaaron
Meteor js had this with the aldeed:autoform package ages ago

------
krrishd
This is pretty amazing. Is it all auto-recursive?

------
r-cid
Cool. Unit tests would be nice.

