我无法理解如何使用一个字段对类进行验证。例如:
case class JGoodNew(
languageid: Long,
title: String
)
val goodNewReads: Reads[JGoodNew] = (
(JsPath \ "languageid").read[Long] and
(JsPath \ "title").read[String](minLength[String](2))
)(JGoodNew.apply _)
这很好用。 但这不起作用:
case class JGoodNew(
title: String
)
val goodNewReads: Reads[JGoodNew] = (
(JsPath \ "title").read[String](minLength[String](2))
)(JGoodNew.apply _)
编译抱怨
类型不匹配; found:String => validators.JGoodNew要求: play.api.libs.json.Reads [?]
为什么会这样?