-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON Reads max and min combinators should work on any Numeric #1363
Conversation
Beforehand it only worked on Int
play2-master-PRs #392 SUCCESS |
def min(m: Int)(implicit reads: Reads[Int]) = | ||
filterNot[Int](ValidationError("error.min", m))(_ < m)(reads) | ||
/** | ||
* Defines a minimum size for a numeric Reads. Combine with `max` using `or`, e.g. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not using the word "size", it's more about the value, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you're right, fixed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no you can commit on your branch and the PR is updated!
On Fri, Jul 19, 2013 at 3:10 PM, Marius Soutier notifications@github.comwrote:
In
framework/src/play-json/src/main/scala/play/api/libs/json/JsConstraints.scala:@@ -112,11 +112,19 @@ trait ConstraintReads {
def seq[A](implicit reads: Reads[A]): Reads[Seq[A]] = Reads.traversableReads[Seq, A]
def map[A](implicit reads: Reads[A]): Reads[collection.immutable.Map[String, A]] = Reads.mapReads[A]
- def min(m: Int)(implicit reads: Reads[Int]) =
- filterNot[Int](ValidationError%28"error.min", m%29)(_ < m)(reads)
- /**
- * Defines a minimum size for a numeric Reads. Combine with
max
usingor
, e.g.Yes you're right... I guess I have to close this PR and submit a new one?
—
Reply to this email directly or view it on GitHubhttps://github.com//pull/1363/files#r5291461
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, see below. value
was just the word I was looking for but then I resorted to size.
Seems OK ;) |
play2-master-PRs #393 SUCCESS |
JSON Reads max and min combinators should work on any Numeric
The
Reads.min
andReads.max
combinators in play-json currently only work on Int, but there's no reason it shouldn't work any any Numeric.