Announcing ReForm: Making forms sound good again with ReasonReact

Gabriel Rubens Abreu
Astrocoders
Published in
2 min readMar 24, 2018

--

ReForm short demo, check the source out at https://github.com/Astrocoders/reform/tree/master/demo

Forms are really complex beasts and can scale to total chaos really quickly if you don’t know how to manage all those field states and validations altogether. The nicest solution in React world is to lift the state of the form to some other component, which will take care, protect and give love to your form state.

In ReactJS there is a nice amount of solutions for dealing with form data management (Formik, Redux Forms, etc).

One of the first things I wanted to try to unleash the power of Reason’s type system was in forms, that’s why we developed ReForm. ReForm still on its early stages and certainly still there is a lot to improve from community suggestions, but we are already loving to deal with its thin API using it for both web and native worlds with React Native.

Yet Another JS Schema Validation Library? Not anymore!

Thanks to Reason type system we do not need to use or create yet another tool to validate data structures for two reasons:

  1. TYPE SYSTEM THAT DOES NOT SUCK!!11! This is the same reason why ReasonReact does not have PropTypes, it’s just already built-in in the language itself. It’s our new mantra: Less framework, more language.
  2. Variants.

ReForm comes with a deadly simple schema usage:

`Required`, `Email` and `Custom` are constructors which belong to the `validation` variant. The implementation is defined in these lines https://github.com/Astrocoders/reform/blob/master/re/ReForm_Validation.re#L15-L27. Yep, the whole implementation of ReForm’s core validation system is done in 12 lines.

Yep, the whole implementation of ReForm’s core validation system is done in 12 lines. That’s the true nature of ReasonML, folks.

PRs and suggestions are welcome at https://github.com/Astrocoders/reform.

Any doubts you can reach us in the wonderful ReasonML Discord server.

Just one more thing

We deployed a live demo using ReForm and ReasonApollo at https://reform-demo.netlify.com/ (the code is in the repo) for you to try! Special thanks to Netlifly and graph.cool for the free tier.

If you want to take a look in other implementation of form state management for ReasonReact take a look in the awesome work of Alex Fedoseev at https://github.com/alexfedoseev/re-formality

Gabriel Rubens Abreu, Head of Research & Development at Astrocoders.com

--

--