Skip to content
This repository has been archived by the owner on Jun 15, 2020. It is now read-only.

Commit

Permalink
Reflect changes in play-scalajs-example
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierBlanvillain committed Jun 23, 2016
1 parent d02c5e5 commit 4a13efc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions play-scalajs-example/js/src/main/scala/Validate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ object Validate {
import Writes._

implicit val format: Format[js.Dynamic, js.Dynamic, User] = Format(
Rule(j => User.format.validate(Ast.from(j))),
Write(u => Ast.to(User.format.writes(u)))
Ast.from andThen User.format,
Write.toWrite(User.format) andThen Ast.to
)

To[VA[User], js.Dynamic](format.validate(json))
Expand Down
2 changes: 1 addition & 1 deletion play-scalajs-example/jvm/app/controllers/Application.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import model.User

class Application()(implicit environment: Environment) extends Controller {
def index = Action {
val write: Write[User, JsValue] = Write(u => Ast.to(User.format.writes(u)))
val write: Write[User, JsValue] = Write.toWrite(User.format) andThen Ast.to
val user: User = User("supercat", 20, Some("e@mail.com"), true)
val json: String = Json.prettyPrint(write.writes(user))
Ok(views.html.index(json))
Expand Down
4 changes: 2 additions & 2 deletions validation-jsonast/js/src/main/scala/Ast.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import scala.scalajs.js
import scala.scalajs.js.JSConverters._

object Ast {
val to: WriteLike[JValue, js.Dynamic] = Write[JValue, js.Any] {
val to: Write[JValue, js.Dynamic] = Write[JValue, js.Any] {
case JNull => null
case JObject (value) => value.mapValues(to.writes).toJSDictionary
case JArray (value) => value.map(to.writes).toJSArray
Expand Down Expand Up @@ -45,7 +45,7 @@ object Ast {
throw new FunctionInJsonException(path)
}

val from: RuleLike[js.Dynamic, JValue] = Rule { j =>
val from: Rule[js.Dynamic, JValue] = Rule { j =>
try {
Valid(unsafeAny2JValue(j, Path))
} catch {
Expand Down
4 changes: 2 additions & 2 deletions validation-jsonast/jvm/src/main/scala/Ast.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package jsonast
import play.api.libs.json._

object Ast {
val to: WriteLike[JValue, JsValue] = Write[JValue, JsValue] {
val to: Write[JValue, JsValue] = Write[JValue, JsValue] {
case JNull => JsNull
case JObject (value) => JsObject(value.mapValues(to.writes))
case JArray (value) => JsArray(value.map(to.writes))
Expand All @@ -22,5 +22,5 @@ object Ast {
case JsNumber (value) => JNumber(value.toString)
}

val from: RuleLike[JsValue, JValue] = Rule(x => Valid(totalFrom(x)))
val from: Rule[JsValue, JValue] = Rule(x => Valid(totalFrom(x)))
}

0 comments on commit 4a13efc

Please sign in to comment.