shakacode / re-formality

Form validation tool for reason-react
https://re-formality.now.sh
MIT License
244 stars 35 forks source link

Complex forms #34

Open baransu opened 6 years ago

baransu commented 6 years ago

I'm trying to migrate plain reducer component that handles updates/validation of my form to re-formality. My form is complex and I'm having a hard time thinking about correct values/fields/updaters. Here is a type of the state:

type state = {
  name: string,
  parts: list(part)
}
and part = {
  image: string,
  title: string,
  subtitle: string,
  buttons: list(button),
}
and button =
  | UrlButton(url)
  | PluginButton(plugin)
and url = {
  id: string,
  caption: string,
  url: string,
}
and plugin = {
  caption: string,
  pluginId: string,
  instanceId: string,
};

For me, it's a really hard example. I want to have all functionality (like validation) available for even most nested values. Current API allows you to manage "one level deep" state really good but more complex state would require a lot of duplicated logic to update nested fields, a lot of fields, values etc.

Do you have any ideas on how we can improve re-formality API to better handle cases like this or how to approach this in application code using current API?

alex35mil commented 6 years ago

This is somewhat similar to #29 and I haven't looked into complex examples yet. Can't promise anything concrete but I'll look into forms w/ complex structure sooner or later.