I am trying figure out my options for validating j...
# http4k
r
I am trying figure out my options for validating json bodies with many required fields so that meaningful error messages are returned, while using lenses (e.g.
Body.auto<EventInDto>().toLens()
). Right now I just get a 400 with “‘body’ must be object” from the CatchLensFailure. If I pass a
lensFailureFn
it seems the most I can do is extract/map a message from the exception, correct? But that seems still too minimal for me. Would it make it make sense to make all the fields on the data class nullable and then do some custom extensions something like
Body.auto<EventInDto>().toLens().validate(validators).toEither()
or something like that. Or I am probably missing more obvious solutions?