open-formulieren / open-forms

Smart and dynamic forms
https://open-forms.readthedocs.io
Other
33 stars 25 forks source link

Create an InferNoLogic Context from Variables Component tab #3597

Open CharString opened 9 months ago

CharString commented 9 months ago

The Variables/Component tab contains KEY and DATA TYPE. This can be used to create a Context for inference:

Passing an example value is enough for InferNoLogic.

{
  "voornaam": "",
  "iban": "",
  "nettoBedragAOQ": 0,
  "werkgevers": [{"nettoLoon": 0, "periodeNettoLoon": "week"}],
  "uitkeringen": {
    "ww": false,
    "anw": false,
    "aow": false,
    "nee": false,
    "wao": false,
    "wia": false,
    "wajong": false,
    "bijstand": false,
    "ziektewet": false
  }
}

This would catch #2941 if the Designer would "correct" the expression to

{"map": [{"var": "iban"}, [{"var": ""}, {"cat": ["Iban: ", {"var": ""}]}]]}

It would infer that "iban" should be an Array, but from the context it follows that it's a String.

So update the calls to infer from #3596 to use this context.

joeribekker commented 7 months ago

Type inference feature was cancelled due to implementation difficulties vs benefits.