You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
427 B
19 lines
427 B
package controllers.common
|
|
|
|
import org.scalactic.Every
|
|
import play.api.libs.json._
|
|
|
|
object Codecs {
|
|
|
|
implicit def everyReads[T](implicit readsT: Reads[T]): Reads[Every[T]] = Reads[Every[T]] { json =>
|
|
json
|
|
.validate[List[T]]
|
|
.flatMap { list =>
|
|
Every.from(list)
|
|
.map(JsSuccess.apply(_))
|
|
.getOrElse {
|
|
JsError.apply("A non-empty list is expected")
|
|
}
|
|
}
|
|
}
|
|
}
|