by softwarelimits · 7y ago · 0 comments
As form code is the most important entry point for security flaws in web applications it is also the most expensive and it is not a good idea having to touch production code for every little backend change. This looks like PHP coding 15 years ago. Do not do that.
Not only this, but I think generally when a backend change happens you want to be aware of it (and fail early, probably in the test/integration phase!) - leaving it potentially as late as runtime could be devastating.
For very basic forms generation from a model is fine, but I think it hits its limits pretty quickly. Imo generating a model from a schema is an okay halfway house.
Regardless, this tool seems pretty nice, and could save me a little boiler plate!
A plain data format (like JSON) should be used to generate Forms, so your client/server side validation is always in sync (DRY).
But this isn't mutually exclusive. You could use this component and generate the implementation (or just plainly transform your data into this with a function). Especially since it leans very heavily on the HTML standard, which has several advantages.
Having a look at the code examples and documentation it would seem ergonomic to just feed JSON into a component that uses this.
I think I have heard of something similar but it didn’t seem to have caught on in any major web frameworks that I know of (strongly typed json API server which generates runtime validators on frontend and backend). Even then most people want control over the presentation of the form and wouldn’t want to create fields from the schema (e.g. a number type is sometimes a slider and sometimes a drop down)
If I have a form anything more complex than a login page, then I usually use some kind of generator based on a schema.