Hmm can you point to the place that made you think that? Maybe you confused storing validation result with storing value? With this change Formality fully delegates value handling to a user so it’s up to a user if value is string
or option(string)
or variant or whatever.
Maybe we should consider handling the field type, not value. I’d love to somehow be able to have bool, int, float, date(?) values.
Yes! Initially, I tried to bind value
type to a field
type, it makes a lot of sense. But I faced type issues, AFAIR w/ internal sets & maps (where field is a key) and validators and gave up. Maybe worth to revisit this direction at some point.
Right now you can have those types by defining your value
type in form config, e.g.:
type value =
| String(string)
| Int(int)
| Float(float)
| Date(Js.Date.t);
And handle state updates and rendering of these types. The reason why it’s not in the core is that lots of forms are just about strings and forcing variant means give up ease of use & apply perf penalty to all users by default. Also, variant way is really a rabbit hole, b/c for every new use case we will have to add new constructor to the type. But by abstracting this type away, we let users decide how they want to shape their state. Simple strings will remain simple strings.