Automatic and customizable compile time transformations between similar case classes and sealed traits/enums, essentially a thing that glues your code. Scala 3 only. Or is it duct 🤔
So while we can configure deeply nested fields with the likes of Field.const and other config options we still lack a way of updating deeply nested fields using the source's value (Field.computed only allows us to use the toplevel source value which falls apart whenever we venture past any of the mandatory fields (eg. in an Option, in a List etc).
Only way of achieving that currently is by supplying a Transformer for those deeply nested fields (but that could also end up changing other fields!).
I propose a new config option like:
Field.deepComputed(_.field1.element.level2.value, _.compute[String](str => ...).
The type param supplied to .compute needs to be correct in relation to the source field under the destination path, the library should return a good error message pointing the user to the right type if it's not the case.
So while we can configure deeply nested fields with the likes of
Field.const
and other config options we still lack a way of updating deeply nested fields using the source's value (Field.computed
only allows us to use the toplevel source value which falls apart whenever we venture past any of the mandatory fields (eg. in an Option, in a List etc).Only way of achieving that currently is by supplying a Transformer for those deeply nested fields (but that could also end up changing other fields!).
I propose a new config option like:
Field.deepComputed(_.field1.element.level2.value, _.compute[String](str => ...)
. The type param supplied to.compute
needs to be correct in relation to the source field under the destination path, the library should return a good error message pointing the user to the right type if it's not the case.