Form field for this enum
Form field for this enum
Binder for play.api.routing.sird router
Binder for play.api.routing.sird router
Example:
scala> import play.api.routing.sird._ scala> import play.api.routing._ scala> import play.api.mvc._ scala> import enumeratum._ scala> sealed trait Greeting extends EnumEntry scala> object Greeting extends PlayEnum[Greeting] { | val values = findValues | case object Hello extends Greeting | case object GoodBye extends Greeting | case object Hi extends Greeting | case object Bye extends Greeting | } scala> val router = Router.from { | case GET(p"/hello/${Greeting.fromPath(greeting)}") => Action { | Results.Ok(s"$greeting") | } | } scala> router.routes res0: Router.Routes = <function1>
Implicit path binder for Play's default router
Implicit path binder for Play's default router
An Enum that has a lot of the Play-related implicits built-in so you can avoid boilerplate.
Note, the binders created here are case-sensitive.
Things included are:
Form("hello" -> MyEnum.formField)
Example:
scala> Json.toJson(Greeting.Hello) res1: JsValue = "Hello"