https://kotlinlang.org logo
#http4k
Title
# http4k
c

Cosmin Marginean

10/10/2023, 7:59 PM
I was looking at the way HTML forms are handled and I was wondering if there is a way to use a Bidi Lens for converting the request to an object? This would be particularly useful for larger forms with multiple fields, or when validation needs to be done on the form object as a whole, for example.
f

fredrik.nordin

10/11/2023, 8:58 AM
BiDiLensSpec.composite()
is probably what you're after.
c

Cosmin Marginean

10/11/2023, 10:37 AM
Interesting, I'll give that a go, thanks!
FYI, this might be a red herring, I couldn't quite figure out how and where this would be wired to parse a response dynamically (based on the type of the form class) I'll raise a feature request for this particular thing. It might not be critical, but it would be nice to have something like:
Copy code
Body.webForm<MyFormObject>().toLens()(request)
or something to that effect. Parsing/configuring individual field lenses isn't always feasible.