Live data from Hacker News

Show HN: Generate React forms from JSON form schemas

github.com

11–20 of 28 posts

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

#11
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

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

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.

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

#12

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

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

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

#14
post #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…

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?

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

#15

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

It's pretty easy to extend JSON Schema with all sorts of other metadata about how a UI should represent the data, or how automated tools should interact with records, making your JSON Schema the single source of truth for your entire data model. The cool thing is that you can actualy write a JSON Schema that extends http://json-schema.org/schema which is the JSON Schema that describes JSON Schema, so you can validate that your use of your custom extensions to JSON Schema aren't misspelled or inconsistent. And that meta-schema can also be validated by http://json-schema.org/schema... It's schemas all the way down!

Getting back to the point, my company is using this exact approach in production, with Python and client-side Javascript consuming the same schema. We have a React component that essentially does what https://github.com/jdorn/json-editor does, but customized for our organization. JSON Schemas make it so easy to add entirely new attributes to our data models and have them consistently validated across the board. Can't imagine doing it any other way.

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

#16

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 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…

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

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

#19
post #12

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

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

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

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

#20
post #3

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.

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