Reputation: 5629
Hi I try to validate in a test the test result in my scala playframework application.
My code looks like this:
implicit val clientIdFormat = Json.format[clientId]
case class clientId(id: Int)
and in the test:
val content = contentAsJson(result).validate(clientId).asOpt.orNull
error is type mismatch
what could be my fail in this case?
Upvotes: 0
Views: 70
Reputation: 37842
The method validate
expects a type parameter, not an argument:
def validate[A](implicit rds: Reads[A]): JsResult[A] = rds.reads(this)
So, you should call it using [clientId]
and not (clientId)
:
val content = contentAsJson(result).validate[clientId].asOpt.orNull
Upvotes: 4