Scala Form Formatter用于接受JSON值

时间:2016-10-03 12:40:22

标签: json forms scala validation playframework-2.0

我正在努力实现以下目标。

val form = Form(
    mapping(
      "stream-name" -> nonEmptyText(minLength = 1),
      "query" -> optional(nonEmptyText),
      "input-stream" -> of(JsArray),
      "archive-ttlsec" -> optional(longNumber),
      "sample-rate" -> optional(of(play.api.data.format.Formats.doubleFormat)),
      "sample-size" -> optional(number),
    )(Data.apply)(Data.unapply)
  )

case class Data(
  `stream-name`: String,
  query: Option[String],
  `input-stream`: JsArray,
  `archive-ttlsec`: Option[Long] = None,
  `sample-rate`: Option[Double] = None,
  `sample-size`: Option[Int] = None,
)

这是我用

创建的Scala Form数据验证程序
  

"输入流" - >的(JsArray)

表单无法验证并正在提供

  

类型不匹配,预期:格式化程序[NonInferedT] actual:JsArray.type

对此有何解决方法?

0 个答案:

没有答案