This repository has been archived by the owner on Jun 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update play-scalajs-example to use a cross compiled validation
- Change the build to publish-local validation, which will be required to compile the example until v2.0 is released
- Loading branch information
1 parent
26dedb5
commit bd842d1
Showing
14 changed files
with
55 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ notifications: | |
email: | ||
false | ||
|
||
script: bash misc/ci.sh | ||
script: bash scripts/ci.sh | ||
|
||
cache: | ||
directories: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
package controllers | ||
|
||
import jto.validation.playjson.Writes | ||
import jto.validation.Write | ||
import jto.validation._ | ||
import jto.validation.jsonast._ | ||
import play.api.Environment | ||
import play.api.libs.json._ | ||
import play.api.mvc._ | ||
|
||
import model.User | ||
|
||
class Application()(implicit environment: Environment) extends Controller { | ||
|
||
def index = Action { | ||
import Writes._ | ||
val write: Write[User, JsObject] = Write.gen[User, JsObject] | ||
val write: Write[User, JsValue] = Write(u => Ast.to(User.format.writes(u))) | ||
val user: User = User("supercat", 20, Some("e@mail.com"), true) | ||
val json: String = Json.prettyPrint(write.writes(user)) | ||
Ok(views.html.index(json)) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,25 @@ | ||
package model | ||
|
||
import jto.validation._ | ||
import jto.validation.jsonast._ | ||
import scala.Function.unlift | ||
|
||
case class User( | ||
name: String, | ||
age: Int, | ||
email: Option[String], | ||
isAlive: Boolean | ||
) | ||
|
||
object User { | ||
import Rules._, Writes._ | ||
implicit val format: Format[JValue, JObject, User] = | ||
Formatting[JValue, JObject] { __ => | ||
( | ||
(__ \ "name").format(notEmpty) ~ | ||
(__ \ "age").format(min(0) |+| max(130)) ~ | ||
(__ \ "email").format(optionR(email), optionW(stringW)) ~ | ||
(__ \ "isAlive").format[Boolean] | ||
)(User.apply, unlift(User.unapply)) | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package jto.validation | ||
package jsonAst | ||
package jsonast | ||
|
||
import play.api.libs.json._ | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...n-jsonast/shared/src/main/scala/Ast.scala → ...sonast/shared/src/main/scala/JValue.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package jto.validation | ||
package jsonAst | ||
package jsonast | ||
|
||
import scala.collection.Map | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package jto.validation | ||
package jsonAst | ||
package jsonast | ||
|
||
import cats.Monoid | ||
|
||
|