Skip to content
Browse files

Fix 2.8.0 build

  • Loading branch information...
1 parent 9aab0bc commit 899064bf5650fa9a7f4611a7b68f007ea761ac0b Joni Freeman committed
View
7 core/json-scalaz/README.md
@@ -69,6 +69,13 @@ composition >=>.
// Creates a function JValue => Result[Person]
Person.applyJSON(field("name"), validate[Int]("age") >=> min(18) >=> max(60))
+Installation
+------------
+
+Add dependency to your SBT project description:
+
+ val lift_json_scalaz = "net.liftweb" %% "lift-json-scalaz" % "XXX"
+
Links
-----
View
5 core/json-scalaz/src/test/scala/net/lifweb/json/scalaz/LottoExample.scala
@@ -18,12 +18,13 @@ object LottoExample extends Specification {
def len(x: Int) = (xs: List[Int]) =>
if (xs.length != x) Fail("len", xs.length + " != " + x) else xs.success
+ // Note 'apply _' is not needed on Scala 2.8.1 >=
implicit def winnerJSON: JSONR[Winner] =
- Winner.applyJSON(field("winner-id"), validate[List[Int]]("numbers") >=> len(6))
+ Winner.applyJSON(field("winner-id"), validate[List[Int]]("numbers") >=> len(6) apply _)
implicit def lottoJSON: JSONR[Lotto] =
Lotto.applyJSON(field("id")
- , validate[List[Int]]("winning-numbers") >=> len(6)
+ , validate[List[Int]]("winning-numbers") >=> len(6) apply _
, field("winners")
, field("draw-date"))
View
9 core/json-scalaz/src/test/scala/net/lifweb/json/scalaz/ValidationExample.scala
@@ -20,16 +20,17 @@ object ValidationExample extends Specification {
val json = JsonParser.parse(""" {"name":"joe","age":17} """)
+ // Note 'apply _' is not needed on Scala 2.8.1 >=
"fail when age is less than min age" in {
// Age must be between 18 an 60
- val person = Person.applyJSON(field("name"), validate[Int]("age") >=> min(18) >=> max(60))(json)
- person.fail.toOption.get.list mustEqual List(UncategorizedError("min", "17 < 18", Nil))
+ val person = Person.applyJSON(field("name"), validate[Int]("age") >=> min(18) >=> max(60) apply _)
+ person(json).fail.toOption.get.list mustEqual List(UncategorizedError("min", "17 < 18", Nil))
}
"pass when age within limits" in {
// Age must be between 16 an 60
- val person = Person.applyJSON(field("name"), validate[Int]("age") >=> min(16) >=> max(60))(json)
- person mustEqual Success(Person("joe", 17))
+ val person = Person.applyJSON(field("name"), validate[Int]("age") >=> min(16) >=> max(60) apply _)
+ person(json) mustEqual Success(Person("joe", 17))
}
}

0 comments on commit 899064b

Please sign in to comment.
Something went wrong with that request. Please try again.