jto / validation

validation api extracted from play

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Format type order

pauldijou opened this issue · comments

I was just wondering... currently, the Format type order is the following:

trait Format[IR, IW, O] extends RuleLike[IR, O] with WriteLike[O, IW]

I don't quite find it fully readable. If we read Rule and Write, it looks like "IR, O, O, IW", which is like "IR, O, IW". It means, "I can go from IR to O and from O to IW". Nice. So why not having:

trait Format[IR, O, IW] extends RuleLike[IR, O] with WriteLike[O, IW]
// Wuuut?
implicit val userFormat = Format.gen[JsValue, BSONDocument, User]

// Ohhhh, I see!
implicit val userFormat = Format.get[JsValue, User, BSONDocument]

That would break existing code. So while it makes sense, nope