I'm using Playframework 2.3.X. I'm trying to construct an action function that validates fields in a JSON request.body. The use case is to build "blocks" of validation that I can then chain together.
However, I can't seem to access the request.body as a JSON inside the action builder. The following doesn't compile. The compiler can't resolve "asJson":
def ValidateJsonBodyAction = new ActionBuilder[Request] {
def invokeBlock[A](request: Request[A], block: (Request[A]) => Future[Result]): Future[Result] = {
val body= request.body.asJson
}
}UPDATE: It could also be that I'm approaching this the wrong way. I'm new to play, so alternative approaches are also welcome.