jto/validation

Laziness when using Format.gen

pauldijou opened this issue · 1 comments

Right now, if you want Format.gen to works with JSON (for example), you need the following:

implicit val entityFormat = {
  import play.api.libs.json._
  import play.api.data.mapping.json.Rules._
  import play.api.data.mapping.json.Writes._
  Format.gen[JsValue, JsObject, Entity]
}

I was wondering if we could merge Rules and Writes implicits into a single Formats object? It's not much about saving one line of code but more about "I just want to use Format macros and I shouldn't bother with exactly what to import in order to make it works, the lib should handle that for me if possible".

implicit val entityFormat = {
  import play.api.libs.json._
  import play.api.data.mapping.json.Formats._
  Format.gen[JsValue, JsObject, Entity]
}
jto commented

I'm not a big fan of Format. I would rather recommend not using it, a I'm considering removal.