I am using PlayFramework 2.6. I have the following classes
case class Account(homePage: URL, name: String)
object Account {
import implicits.ReadsWrites.urlFormat
implicit val format: Format[Account] = Json.format[Account]
}
And account
is an optional field of type Account
case class IdentifiedGroup(objectType: String,
name: Option[String],
member: Option[Seq[Agent]],
mbox: Option[URI],
mboxSHA1SUM: Option[String],
openID: Option[URI],
account: Option[Account]) extends Group
When name
field in Account
is not a string but an object such as "name": { "key": "this should fail" }
Then when I apply reads on IdentifiedGroup, the account
will be None.
But the expected behaviour is that if account
is present and invalid then I want JsError as a result instead.
I've been googling for more than a day and still can't seem to find the right answer :(
Thanks