reform
reform copied to clipboard
Reform 3.0
We will start writing Reform 3 once the Trailblazer 2.1 release along with the new website and PRO launch is out. This issue is in a state of flux, defining the planned API.
For a discussion about why I really want to abandon Reform 2.x, here's a talk that summarizes it: https://www.youtube.com/watch?v=6eXDAQpaUV8
Design keys
- Immutability: never again will we make that mistake and provide an API that allows changing an object once it's created.
- Reduced internal complexity: we probably won't need Representable for parsing anymore.
- Coercion/typing: use
Dry::Struct
s that are orchestrated via a simplified twin.
validate
result = Form.validate(form, params)
Fills out the form, and runs the validations. The filled-out form is somehow in result
.
Fill-out
We used to have pre-populators to fill-out a form before its validation. Some people even used Form#validate
multiple times :woman_facepalming:. The problem here was that this will also run coercion, which is often not wanted and wrong! (e.g. when you serialized the already validated data and then want to display a "correct me" form).
Form.fill_out(form, data)
This bypasses validation and coercion.
Allow dynamic collection :sources do ... end
s where each source item can have different property
s depending on the underlying item model. Allow that also for the incoming input hash.