maybetrinity
06/15/2018, 7:36 AMdata class Meeting(
val date: java.time.LocalDate,
val time: String
)
Based on the docs I would do
val MeetingBody = Body.auto<Meeting>().toLens()
let’s say I make a request with
{date: "2017-01-22", time: "3:00 PM"}
when I try MeetingBody.extract(request: Request)
I get
Cannot construct instance of `java.time.LocalDate` (no Creators, like default construct, exist): no String-argument constructor/factory method to deserialize from String value ('2017-07-12')
at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: Meeting["date"])
I would have expected this(^) to work as the following does:
val queryResultLens = Query.localDate().required("date")
queryResultLens.extract(Request(Method.GET, "/?date=2017-01-22"))
Similarly, if I wanted to ensure the time matched a given regex, I can do this with a query param:
val queryResultLens = Query.regex("v(\\d+)").required("time")
queryResultLens.extract(Request(Method.GET, "/?time=v123"))
but to do it with a body param i'd need to tell Jackson how I want it to be deserialized or?