Chapters

3.0 Reform 3 Documentation

The Reform-3 (trailblazer-form) section is still WIP (as of November 2023).

We’re going to announce a presentable release of R3 in public. Currently, we’re collecting doc notes here.

Internals

  • Form.deserialize

returns Form::Deserialized

  • Form::Deserialized

created in [NestedDeserializer]

  • NestedDeserializer

generic_input = # input going into the nested "form"
          ->(ctx, value:, **) {
            {
              populated_instance: DeserializedFields.new,
              form_instance:      nested_form.new,  # we use this as the {exec_context} for filters.
              input:              value,
            }
          }

Railway.Subprocess(nested_deserializer).merge


Railway.Out() => ->(ctx, populated_instance:, form_instance:, **) {
              # FIXME: use kw for {:model_from_populator}
              {
                value: Form::Deserialized.new(nested_schema, form_instance, populated_instance, ctx, paired_model: ctx[:paired_model]), # this is used in {set}.
                # Here we would have to return the mutated twin
              }
  • set

populated_instance = populated_instance.merge(key => value)
  • property(name, &block)
  1. options[:nested_block] = &block
  2. normalizer.()
  3. normalizer Class.new(Form)… nested_block => options[:nested]
  4. add_property_to_deserializer(, nested:, ) # note: {:nested} is already there and a Form subclass!
  5. Class.new(Deserialize::Property::Read, &parse_block)

Internals