I'm using play 2.2.0 Reads for validating incoming request in my application.
I'm trying to implement a very simple thing with json API. I have a json like this:
{
"field1": "some value",
"field2": "some another value"
}
I already have Reads
that checks for other stuff like minimal length
case class SomeObject(field1: String, field2: String)
implicit val someObjectReads = (
(__ \ "field1").read(minLength[String](3)) ~
(__ \ "field2").read(minLength[String](3))
)(SomeObject)
I want to create a parser combinator that will match values of two fields and return JsSuccess
if values are equal and otherwise JsError
and combine it with existing Reads
.
How can I achieve this?
UPDATE: clarified the question and changed the code.